Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a problem in my program where 2 extra threads get created from a block of code that uses the winapi. I saw nothing in the documentation of the functions used that indicates that the threads would be created. But if I don't run this block my program has 1 thread and if I do then it has 3. This is the code block:

C++
if (!(hdc = GetDC(hwd))                           ||
    !(PixelFormat = ChoosePixelFormat(hdc, &pfd)) ||
    !(SetPixelFormat(hdc,PixelFormat, &pfd))      ||
    !(hrc = wglCreateContext(hdc)))
{
    DestructWindow();
    return false;
}


Is there any way to get rid of those 2 extra threads or are they supposed to be there?
Posted
Comments
Philippe Mori 17-Sep-11 18:16pm    
If you don't create them, then don't get rid of them and don't worry too much about that.

1 solution

James,

The Microsoft GDI+ library gdiplus.dll will spawn worker threads within your process. I don't think there is any documented way to control this. You can probably verify this by downloading Process Explorer[^] and right-clicking your process and selecting the 'Threads' tab. If you have Debugging Tools for Windows[^] installed and your symbols properly setup you will even be able to inspect the call stack.

Best Wishes,
-David Delaune
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900