I've searched in google, but cannot find how can I add my own function to Threadpool. I have a function with signature void MyFunction(void *param);
. How I can create Threadpool and add this function for assynchronos execution. I know that exist TrySubmitThreadpoolCallback()
function, but I cannot understand how to use it. 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
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
).
-
Thanks for reply!Imagine that i've ghanged signature, and how can i add this function to threadpool. – abilash Oct 20 '12 at 8:48
TrySubmitThreadpoolCallback
doesn't look that difficult to use, but for the callback your function signature is not appropriate. – ta.speot.is Oct 20 '12 at 8:34