Article View: borland.public.cppbuilder.nativeapi
Article #1318Re: Differences between Semaphore and Mutex
From: Danny
Date: Sun, 16 Sep 2007 18:14
Date: Sun, 16 Sep 2007 18:14
26 lines
1744 bytes
1744 bytes
Hi Dennis,
thank you for your detailed explanation.
Fundamentally I have a TThread class, and when I close my application, the
terminate event isn't come execute, and so I need to synchronization.
Currently I've:
void __fastcall TFMain::FormClose(TObject *Sender, TCloseAction &Action)
{
HANDLE h=CreateSemaphore(NULL,0,1,"PddSem");
Control->Terminate();
while(WaitForSingleObject(h,500)!=WAIT_OBJECT_0)
Application->ProcessMessages();
::CloseHandle(h);
}
void __fastcall TThreadControl::TerminateEvent(TObject *Sender)
{
.... my code .....
HANDLE h=OpenSemaphore(SEMAPHORE_ALL_ACCESS,false,"PddSem");
ReleaseSemaphore(h,1,NULL);
CloseHandle(h);
}
However I'll try with TCriticalSection class.
Thank you
Technical Details
Message-ID:
<46ed7265@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46ecd663@newsgroups.borland.com> <kcaqe3d7a9ahqkl01dpp52rerc4g54o9et@4ax.com> <46ed637d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6b2ce248fe32d850 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Danny" <danny2912@libero.it> From: "Danny" <danny2912@libero.it> Newsgroups: borland.public.cppbuilder.nativeapi References: <46ecd663@newsgroups.borland.com> <kcaqe3d7a9ahqkl01dpp52rerc4g54o9et@4ax.com> <46ed637d$1@newsgroups.borland.com> Subject: Re: Differences between Semaphore and Mutex Date: Sun, 16 Sep 2007 20:14:07 +0200 Lines: 28 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 NNTP-Posting-Host: 151.49.234.211 Message-ID: <46ed7265@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1189966437 151.49.234.211 (16 Sep 2007 11:13:57 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail