Article View: borland.public.cppbuilder.nativeapi
Article #8740Re: Thread WaitFor() ....waits forever
From: Daniel Stevenson
Date: Wed, 22 Sep 2004 06:58
Date: Wed, 22 Sep 2004 06:58
42 lines
2288 bytes
2288 bytes
I'm not sure if this is meant to be working but if I comment out the WaitForSingleObject(hThread, INFINITE) then it seams to work I thought i had tried this previously and was causing a AV. is this because the Thread is terminating prior to the WaitForSingleObject(hThread, INFINITE) is executed? "Daniel Stevenson" <d.stevenson@ocreage.com.au> wrote in message news:415120dc@newsgroups.borland.com... > > > > > You are mis-using the thread pointer. See below. > > > > > delete MyForm1; > > > MyForm1 = NULL; > > > > You should never call 'delete' on a thread that has its FreeOnTerminate > > property set to true. > > I don't actually use delete when terminating my thread. The above delete is > deleting my form after the thread is supposed to be terminated. > > > > > That is because you are deadlocking the code. WaitForSingleObject() is > > waiting for the thread to terminate, but the thread is waiting for the > main > > thread to process the Synchronize() requests so that it can then continue > on > > and eventually detect that it needs to terminate itself. > > > > I sort of understand what you are implying but I'm not sure how to stop my > thread from being deadlocked. As far as I know, the Synchronize function is > fairly straight forward and should be able to be completed. > > >
Technical Details
Message-ID:
<415122ad@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<415108cd$1@newsgroups.borland.com> <4151128c$1@newsgroups.borland.com> <415120dc@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1897390e79ed181f X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Daniel Stevenson" <d.stevenson@ocreage.com.au> Newsgroups: borland.public.cppbuilder.nativeapi References: <415108cd$1@newsgroups.borland.com> <4151128c$1@newsgroups.borland.com> <415120dc@newsgroups.borland.com> Subject: Re: Thread WaitFor() ....waits forever Date: Wed, 22 Sep 2004 16:58:51 +1000 Lines: 44 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 202.174.228.150 Message-ID: <415122ad@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095836333 202.174.228.150 (21 Sep 2004 23:58:53 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail