简体   繁体   English

WinAPI线程池

[英]WinAPI Threadpool

I've searched in google, but cannot find how can I add my own function to Threadpool. 我已经在Google中搜索过,但是找不到如何将自己的函数添加到Threadpool中。 I have a function with signature void MyFunction(void *param); 我有一个签名void MyFunction(void *param);的函数void MyFunction(void *param); . How I can create Threadpool and add this function for assynchronos execution. 我如何创建Threadpool并添加此函数以进行assynchronos执行。 I know that exist TrySubmitThreadpoolCallback() function, but I cannot understand how to use it. 我知道存在TrySubmitThreadpoolCallback()函数,但是我不明白如何使用它。 I'll be very glad to see simple example. 我将很高兴看到简单的示例。

In order to be able to use TrySubmitThreadpoolCallback you should change signature of your function to 为了能够使用TrySubmitThreadpoolCallback您应该将函数的签名更改为

void CALLBACK MyFunction( PTP_CALLBACK_INSTANCE Instance, void* Context );

And then you can use it without problem. 然后您可以毫无问题地使用它。 Remember that in windows most callbacks should have the CALLBACK in their definition, because default calling convention in C is __cdecl but in Windows API it is usually __stdcall (read it CALLBACK ). 请记住,在Windows中,大多数回调都应在其定义中包含CALLBACK ,因为C中的默认调用约定是__cdecl但在Windows API中,它通常是__stdcall (请参阅CALLBACK )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM