Important note for documentation of wxThread::Delete

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
silver.moon
Experienced Solver
Experienced Solver
Posts: 67
Joined: Fri Feb 20, 2015 6:13 am

Important note for documentation of wxThread::Delete

Post by silver.moon »

While working with threads and wxThread::Delete I came across a strange behaviour.
That is, if you call Delete in some event handler, while that handler has not yet finished, other events are getting processed.

Code: Select all

void MyClass::OnEvent()
{
	print 1;
	m_thread->Delete();
	print 2;
}

void MyClass::OnAnotherEvent()
{
	print 3;
}
And the output is ..... 1 3 2

Luckily, I found this wiki page https://wiki.wxwidgets.org/WxThread which says

Code: Select all

Delete(), while waiting for the thread to destroy itself, processes messages.
This should be mentioned in the docs. Its quite important I guess.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Important note for documentation of wxThread::Delete

Post by doublemax »

This should be mentioned in the docs. Its quite important I guess.
It is: http://docs.wxwidgets.org/trunk/classwx ... db85f686d4

Check the "waitmode" parameter.
Use the source, Luke!
User avatar
silver.moon
Experienced Solver
Experienced Solver
Posts: 67
Joined: Fri Feb 20, 2015 6:13 am

Re: Important note for documentation of wxThread::Delete

Post by silver.moon »

Thanks, I see it now.

I just looked at the function signature, "wxThreadWait waitMode = wxTHREAD_WAIT_BLOCK" so thought that its using block mode.
But looks like I need to specify it, on MSW
Post Reply