🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2062

Re: Need help with Mutex

#2062
From: Dennis Jones
Date: Sat, 28 Apr 2007 17:12
32 lines
1911 bytes
"SubZero" <g_ates@hotmail.com> wrote in message 
news:4633777f$1@newsgroups.borland.com...

> void inline __fastcall lockCriticalSection(TCriticalSection 
> *criticalSection)
> {
>  HANDLE hMutex;
>
>  // Create a mutex with no initial owner.
>
>  hMutex = CreateMutex(
>   NULL,                       // no security attributes
>   true,                      // initially owned
>   String((int)(void*)criticalSection).c_str());  // name of mutex
>
>  DWORD dwWaitResult;
>
>  // Request ownership of mutex.
>
>  if(hMutex)
>  {
>   dwWaitResult = WaitForSingleObject(
>   hMutex,   // handle to mutex
>   5000L);   // five-second time-out interval

Perhaps I am mistaken, but it looks to me like the problem is obvious...your 
comment says, "Create a mutex with no initial owner", but the code creates 
it owned (conflicts with the comment).  Then you attempt to wait for the 
mutex, and 5 seconds later, due to timeout, the exception is thrown.

- Dennis 
Technical Details
Message-ID: <4633807b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4633777f$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,28184df4065864d1
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Dennis Jones" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4633777f$1@newsgroups.borland.com>
Subject: Re: Need help with Mutex
Date: Sat, 28 Apr 2007 10:12:30 -0700
Lines: 34
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 71.245.109.58
Message-ID: <4633807b$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1177780347 71.245.109.58 (28 Apr 2007 10:12:27 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail