About ThreadPool.QueueUserWorkItem and ThreadPool.RegisterWaitForSingleObject

  • Thread starter Thread starter Henri
  • Start date Start date
H

Henri

Might sound a stupid question but need to be sure:

When you call ThreadPool.QueueUserWorkItem and
ThreadPool.RegisterWaitForSingleObject passing a New object as state

e.g.: ThreadPool.QueueUserWorkItem(AddressOf MyCallBack, New
MyObject(myArg1, myArg2))

the new object MyObject is instantiated just before QueueUserWorkItem is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitForSingleObject, isn't it?

Thanks

Henri
 
Yes, a reference to a brand new MyObject object will be passed into
the method. You also have to create the object before
RegisterWaitForSingleObject.
 
Thanks,
So the new object will be instantied by the main thread, and MyCallBack will
then be processed by another thread from the threadPool, right?

Henri
 
Henri said:
*Might sound a stupid question but need to be sure:

When you call ThreadPool.QueueUserWorkItem and
ThreadPool.RegisterWaitForSingleObject passing a New object as state

e.g.: ThreadPool.QueueUserWorkItem(AddressOf MyCallBack, New
MyObject(myArg1, myArg2))

the new object MyObject is instantiated just before QueueUserWorkIte
is
called, and not just before MyCallBack is called, isn't it?
It's the same for RegisterWaitForSingleObject, isn't it?

Thanks

Henri *

-- I tried to use the RegisterWaitForSingleObject function but delhp
does not recognise the function variables... How did you solve thi
problem.
( The WaitForSingleObject function is no problem)

thanks in advance

Douw


-
Douw
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top