Re: WaitForSingleObject() failing?

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



Hi Scott,

On Wed, 04 Jan 2006 08:22:45 -0500, "Scott McPhillips [MVP]"
<org-dot-mvps-at-scottmcp> wrote:

> It is safer to create the thread with CREATE_SUSPENDED, then
>do pWorkerThread->m_bAutoDelete = FALSE, then
>pWorkerThread->ResumeThread().

Always when a problem with the lifetime of a thread comes up, these
three lines of code are posted as THE solution.

Why not simple and easy, and only one line of code?

UINT xy::ThreadProc (LPVOID foo)
{
AfxGetThread()->m_bAutoDelete = FALSE;

while (true)
{
// thread code
}
return 0;
}

I always use this solution and never had any problems.

I feel like walking on thin ice, because I never see my code as a
possible solution ;-)

Best Regards
Walter

.



Relevant Pages

  • Re: IMF and SCL Level - Our Messages to customers are 7 and 8!
    ... doing relaying that's the safer thing anyway) Creating a new one will ... allow you to run the IMF against inbound stuff and not against the ... Prev by Date: ...
    (microsoft.public.exchange2000.admin)
  • Re: WaitForSingleObject() failing?
    ... > Hi Scott, ... > Always when a problem with the lifetime of a thread comes up, ... A lot can happen between the time that the main thread starts a worker ... It's safer for the main thread to start the worker suspended, ...
    (microsoft.public.vc.mfc)
  • Re: Here is A URL (2NR) Topper, you forgot about the Impersonators
    ... Is there any chance in this lifetime that you will become clued in enough to ... realize that you're one of the reasons its still here? ... Keep replying to it ... Prev by Date: ...
    (misc.transport.trucking)
  • Re: Capacitor choice for switching PSU?
    ... Do you care about size, lifetime at your operating temperature, ... sticker price, ... ... Prev by Date: ...
    (sci.electronics.design)
  • Re: How can I transfer an Excel worksheet onto an Access database?
    ... it is probably safer to assume that I know absolutely nothing about ... The worksheet is already set up, but I guess what I need to know is ... > www.experts-exchange.com - experts compete for points to answer your ... Prev by Date: ...
    (microsoft.public.access.gettingstarted)