Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>The easiest thing</strong> </p> <p>for you to do, would be to simply invoke the windows API <strong>QueueUserWorkItem</strong>. All you have to specify is the function that the thread will execute and the input passed to it. A thread pool will be automatically created for you and the jobs executed in it. New threads will be created as and when is required.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms684957(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms684957(VS.85).aspx</a></p> <p><strong>More Control</strong></p> <p>You could have a more detailed control using another set of API's which can again manage the thread pool for you - </p> <p><a href="http://msdn.microsoft.com/en-us/library/ms686980(VS.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms686980(VS.85).aspx</a></p> <p><strong>Do it yourself</strong></p> <p>If you want to control all aspects of your thread creation and the pool management you would have to create the threads yourself, decide how they should end , how many to create etc (beginthreadex is the api you should be using to create threads. If you use MFC you should use AfxBeginThread function).</p> <p><strong>Send jobs to worker threads - Io completion Ports</strong></p> <p>In this case, you would also have to worry about how to communicate your jobs - i would recommend IoCOmpletionPorts to do that. It is the most scalable notification mechanism that i currently know of made for this purpose. It has the additional advantage that it is implemented in the kernel so you avoid all kinds of dead loack sitautions you would encounter if you decide to handroll something yourself. </p> <p>This article will show you how with code samples - </p> <p><a href="http://blogs.msdn.com/larryosterman/archive/2004/03/29/101329.aspx" rel="noreferrer">http://blogs.msdn.com/larryosterman/archive/2004/03/29/101329.aspx</a></p> <p><strong>Communicate Back - Windows Messages</strong></p> <p>You could use windows messages to communicate the status back to your parent thread since it is doing the message wait anyway. use the PostMessage function to do this. (and check for errors)</p> <p>ps : You could also allocate the data that needs to be sent out on a dedicated pointer and then the worker thread could take care of deleting it after sending it out. That way you avoid the return pointer traffic too. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload