timmay3141
Programmer
In a program I'm working on (the same program that was causing me trouble a couple months ago that I posted about then, if you remember), I have a thread similar to this. It does more, but I have left out the unimportant parts:
UINT MyViewClass::HandleThread(LPVOID lp)
{
MyViewClass* pView = (MyViewClass*)lp;
MyDocClass* pDoc = pView->GetDocument();
while(1)
{
CDC* pDC = pView->GetDC(); // Line 8
pDoc->DrawStuff(pDC); // Line 9
::Sleep(100);
}
return 0;
}
Using the Stress Utility, I've managed to find the source of the problems. When I leave it as is, the GDI32 drops drastically, along with the User % and to a lesser extent the GDI%. When I comment out line 9, it doesn't help at all. However, when I comment out the lines 8 and 9, I don't lose anything. I took this to mean that the repeated GetDC calls are reaking havoc on my system (it lags really bad after a while). What is the problem, and what can I do to fix it?
UINT MyViewClass::HandleThread(LPVOID lp)
{
MyViewClass* pView = (MyViewClass*)lp;
MyDocClass* pDoc = pView->GetDocument();
while(1)
{
CDC* pDC = pView->GetDC(); // Line 8
pDoc->DrawStuff(pDC); // Line 9
::Sleep(100);
}
return 0;
}
Using the Stress Utility, I've managed to find the source of the problems. When I leave it as is, the GDI32 drops drastically, along with the User % and to a lesser extent the GDI%. When I comment out line 9, it doesn't help at all. However, when I comment out the lines 8 and 9, I don't lose anything. I took this to mean that the repeated GetDC calls are reaking havoc on my system (it lags really bad after a while). What is the problem, and what can I do to fix it?