From: Peter Gordon on
I too wait for a joinable thread. I had several problems until I
separated the Windows code from the Unix/Linux code.

This is what I do, and it hasn't failed yet.

#ifdef __WINDOWS__
if (!m_thread->IsAlive()) {
m_thread->Delete() ;
delete m_thread ;
m_thread = NULL ;
}
#endif

#ifdef __UNIX__
if (!m_thread->IsAlive()) {
wxThread::ExitCode result = m_thread->Wait() ;
if ( result != (wxThread::ExitCode)(-1) ) {
m_thread->Delete() ;
delete m_thread ;
}
m_thread = NULL ;
}
#endif

Peter

On Tue, 2006-02-21 at 16:04 +1100, Gian Lorenzetto wrote:
> Ryan,
>
> Better, but I would still like to see mention of the fact that Wait()
> requests that the thread end ASAP, and that there is no need to call
> Delete() on a JOINABLE thread. This would fit nicely in the "wxThread
> Deletion" section.
>
> Actually, why does Delete() exist if Wait() does the same thing? (Or vice
> versa?) Or is one only for detached threads?
>
> Clearly I'm still confused :)
>
> Gian
>
> > -----Original Message-----
> > From: Ryan Norton [mailto:wxprojects(a)comcast.net]
> > Sent: Saturday, 18 February 2006 10:13 PM
> > To: wx-users(a)lists.wxwidgets.org
> > Subject: RE: wxThread
> >
> > >I think the documentation for wxThread needs to be somewhat clearer as
> > > to
> > > the uses of Delete() and Wait().
> >
> > Oh, I do too - I've attached my rewritten version (in HTML format)
> > - let me know what you think (I've submitted it as a patch as well
> > as I can always improve it later [if that is possible, I almost think
> > I went a little overboard with the info already...]).
> >
> > RN
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "Mohd Radzi Ibrahim" on
The way I understand is this:

Wait() is used for the main thread to 'wait' for the completion of thread.
This will only work on JOINABLE thread. Once waiting is done, main thread
can safely delete using 'delete pThread' instead of the Delete(), since the
Delete() only work if the thread is still alive....

Delete() is used to interfere with the running of the thread, by flagging
the thread to 'terminate asap'. That depends on the thread to always check
TestDestroy() as frequent as possible; getting true from it means that the
thread must exit immediately. Thereafter the normal C++ delete (from the
main thread) can be used to 'delete' the thread.

I've been using this for quite some time; seems OK.

best regards,
Radzi.

----- Original Message -----
From: "Gian Lorenzetto" <gian(a)anatomics.com>
To: <wx-users(a)lists.wxwidgets.org>
Sent: Tuesday, February 21, 2006 1:04 PM
Subject: RE: wxThread


> Ryan,
>
> Better, but I would still like to see mention of the fact that Wait()
> requests that the thread end ASAP, and that there is no need to call
> Delete() on a JOINABLE thread. This would fit nicely in the "wxThread
> Deletion" section.
>
> Actually, why does Delete() exist if Wait() does the same thing? (Or vice
> versa?) Or is one only for detached threads?
>
> Clearly I'm still confused :)
>
> Gian
>
>> -----Original Message-----
>> From: Ryan Norton [mailto:wxprojects(a)comcast.net]
>> Sent: Saturday, 18 February 2006 10:13 PM
>> To: wx-users(a)lists.wxwidgets.org
>> Subject: RE: wxThread
>>
>> >I think the documentation for wxThread needs to be somewhat clearer as
>> > to
>> > the uses of Delete() and Wait().
>>
>> Oh, I do too - I've attached my rewritten version (in HTML format)
>> - let me know what you think (I've submitted it as a patch as well
>> as I can always improve it later [if that is possible, I almost think
>> I went a little overboard with the info already...]).
>>
>> RN
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "Gian Lorenzetto" on
Thanks,

This makes sense with what I'm seeing in my test app.

The manual really needs to be updated to make this clearer, perhaps
incorporating Ryan's changes with your description below.

I don't have time to make the changes, but I'll happily read and give
feedback on any proposed changes.

Cheers,
Gian

> -----Original Message-----
> From: Mohd Radzi Ibrahim [mailto:mradzi(a)pc.jaring.my]
> Sent: Tuesday, 21 February 2006 7:48 PM
> To: wx-users(a)lists.wxwidgets.org
> Subject: Re: wxThread
>
> The way I understand is this:
>
> Wait() is used for the main thread to 'wait' for the completion of thread.
> This will only work on JOINABLE thread. Once waiting is done, main thread
> can safely delete using 'delete pThread' instead of the Delete(), since
the
> Delete() only work if the thread is still alive....
>
> Delete() is used to interfere with the running of the thread, by flagging
> the thread to 'terminate asap'. That depends on the thread to always check
> TestDestroy() as frequent as possible; getting true from it means that the
> thread must exit immediately. Thereafter the normal C++ delete (from the
> main thread) can be used to 'delete' the thread.
>
> I've been using this for quite some time; seems OK.
>
> best regards,
> Radzi.
>
> ----- Original Message -----
> From: "Gian Lorenzetto" <gian(a)anatomics.com>
> To: <wx-users(a)lists.wxwidgets.org>
> Sent: Tuesday, February 21, 2006 1:04 PM
> Subject: RE: wxThread
>
>
> > Ryan,
> >
> > Better, but I would still like to see mention of the fact that Wait()
> > requests that the thread end ASAP, and that there is no need to call
> > Delete() on a JOINABLE thread. This would fit nicely in the "wxThread
> > Deletion" section.
> >
> > Actually, why does Delete() exist if Wait() does the same thing? (Or
vice
> > versa?) Or is one only for detached threads?
> >
> > Clearly I'm still confused :)
> >
> > Gian
> >
> >> -----Original Message-----
> >> From: Ryan Norton [mailto:wxprojects(a)comcast.net]
> >> Sent: Saturday, 18 February 2006 10:13 PM
> >> To: wx-users(a)lists.wxwidgets.org
> >> Subject: RE: wxThread
> >>
> >> >I think the documentation for wxThread needs to be somewhat clearer as
> >> > to
> >> > the uses of Delete() and Wait().
> >>
> >> Oh, I do too - I've attached my rewritten version (in HTML format)
> >> - let me know what you think (I've submitted it as a patch as well
> >> as I can always improve it later [if that is possible, I almost think
> >> I went a little overboard with the info already...]).
> >>
> >> RN
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "Gian Lorenzetto" on
Thanks,

I've only built my app on windows so far, but I will eventually need Mac and
Linux, so this will no doubt save me chasing my tail when I get onto a Linux
box :)

Gian

> -----Original Message-----
> From: Peter Gordon [mailto:peter(a)pg-consultants.com]
> Sent: Tuesday, 21 February 2006 6:42 PM
> To: wx-users(a)lists.wxwidgets.org
> Subject: RE: wxThread
>
> I too wait for a joinable thread. I had several problems until I
> separated the Windows code from the Unix/Linux code.
>
> This is what I do, and it hasn't failed yet.
>
> #ifdef __WINDOWS__
> if (!m_thread->IsAlive()) {
> m_thread->Delete() ;
> delete m_thread ;
> m_thread = NULL ;
> }
> #endif
>
> #ifdef __UNIX__
> if (!m_thread->IsAlive()) {
> wxThread::ExitCode result = m_thread->Wait() ;
> if ( result != (wxThread::ExitCode)(-1) ) {
> m_thread->Delete() ;
> delete m_thread ;
> }
> m_thread = NULL ;
> }
> #endif
>
> Peter
>
> On Tue, 2006-02-21 at 16:04 +1100, Gian Lorenzetto wrote:
> > Ryan,
> >
> > Better, but I would still like to see mention of the fact that Wait()
> > requests that the thread end ASAP, and that there is no need to call
> > Delete() on a JOINABLE thread. This would fit nicely in the "wxThread
> > Deletion" section.
> >
> > Actually, why does Delete() exist if Wait() does the same thing? (Or
vice
> > versa?) Or is one only for detached threads?
> >
> > Clearly I'm still confused :)
> >
> > Gian
> >
> > > -----Original Message-----
> > > From: Ryan Norton [mailto:wxprojects(a)comcast.net]
> > > Sent: Saturday, 18 February 2006 10:13 PM
> > > To: wx-users(a)lists.wxwidgets.org
> > > Subject: RE: wxThread
> > >
> > > >I think the documentation for wxThread needs to be somewhat clearer
as
> > > > to
> > > > the uses of Delete() and Wait().
> > >
> > > Oh, I do too - I've attached my rewritten version (in HTML format)
> > > - let me know what you think (I've submitted it as a patch as well
> > > as I can always improve it later [if that is possible, I almost think
> > > I went a little overboard with the info already...]).
> > >
> > > RN
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org