Re: debugging multithreaded app

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tim Robinson (tim.at.gaat.freeserve.co.uk_at_nowhere.com)
Date: 03/16/05


Date: Wed, 16 Mar 2005 21:38:45 -0000


"Bruno van Dooren" <microvax@hotmail.com> wrote in message
news:eW6ZXylKFHA.1176@TK2MSFTNGP15.phx.gbl...
> i was debugging a multithreaded app, when i stumbled across some weird
> behavior of the debugger.
>
> in the destructor of my main object i send a stop event to the worker
> thread, and then wait until that thread has finished.
>
> m_Stop = true;
> while(GetExitCodeThread() == STILL_RUNNING)
> Sleep(50);
[...]

I can't claim any insight into your problem, but this is the traditional way
to wait for a thread to exit:

m_Stop = true;
WaitForSingleObject(m_ThreadHandle, INFINITE);

There's no need to poll, as the original code does.

-- 
Tim Robinson
MVP, Windows SDK 


Relevant Pages

  • Re: debugging multithreaded app
    ... >> i was debugging a multithreaded app, when i stumbled across some weird ... >> in the destructor of my main object i send a stop event to the worker ... > Tim Robinson ...
    (microsoft.public.dotnet.languages.vc)
  • Re: .Net Application crash No exception Thrown
    ... exception being thrown. ... This occurs both when we are debugging and ... like I had told it to exit the code. ... on catching anything. ...
    (microsoft.public.dotnet.framework)
  • Re: if clause
    ... 3: if (permission < operator) ... Some people think a function should have just ONE clear exit ... We have a whole runtime-enabled logger system so, as long as you log the entry and exit, debugging is easy and the code is easy to read. ... I'm speaking as someone who might not be able to run a debugger on live code (I maintain chunks that are compiled with older compilers that have crufty debuggers that don't run on later releases of Windows, ...
    (comp.lang.c)
  • Re: Random Crash with no exception
    ... Charles ... exception being thrown. ... This occurs both when we are debugging and ... like I had told it to exit the code. ...
    (microsoft.public.dotnet.languages.vb)
  • =?ISO-8859-1?Q?Re=3A_Label_und_Button_Text_dynamisch_=E4ndern?=
    ... If Sperre_pruefen= True Then Exit Sub ... Nochwas zu Exit Sub: Ich versuche, ... Gerade bei längeren Routinen kann es im Debugging nervig sein, ... dass das eine Grundsatzdiskussion über GoTo auslösen kann. ...
    (microsoft.public.de.german.entwickler.dotnet.vb)