ungraceful worker thread termination Topic is solved

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
MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

ungraceful worker thread termination

Post by MoonKid » Fri Mar 04, 2011 2:00 am

When I exit my application I get two error messages that I don't know how to interpret.

Code: Select all

Error: Can not wait for thread termination.

Code: Select all

Error: Ungraceful worker thread termination.
I don't use wxThread or something like that. I'm using some wxTimer derived objects. I take care that they are stoped and deleted before closing the application. But I think it would be really needed but I do.

What does this errore messages mean?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2020
Joined: Sun Jan 03, 2010 5:45 pm

Post by PB » Fri Mar 04, 2011 6:43 am

Are you using a wxFileSystemWatcher class (wxFSW)? I think the only source of the "Ungraceful worker thread termination" error is wxFSW on MS Windows. If you do, try checking the debug output with wxTRACE_FSWATCHER on. This being said, wxFSW worker thread is finished automatically from its destructor, I haven't encountered this error when tinkering with wxFSW implementation or doing extensive stress testing of my wxFSW patch.

BTW, I don't see any reason why wxTimer should use threads, it should rely on timer infrastructure provided by OS, but I maybe wrong?

MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid » Fri Mar 04, 2011 9:01 am

Yes I am using wxFileSystemWatcher class. And I do a delete on it in the dtor of my application class.
PB wrote:If you do, try checking the debug output with wxTRACE_FSWATCHER on.
What do you exactly mean with this? I found wxTRACE_FSWATCHER in the source.

Code: Select all

#define wxTRACE_FSWATCHER "fswatcher"
How can I use this for debug output?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2020
Joined: Sun Jan 03, 2010 5:45 pm

Post by PB » Fri Mar 04, 2011 10:03 am

1. Use Debug Build
2. Call wxLog::AddTraceMask(wxTRACE_FSWATCHER) when your app starts, e.g. in wxApp::OnInit(), see fswatcher sample.
3. After you get the error, check the output of trace calls. I use MSVS, so I can see it in the Output window (Show output from debug) of the IDE.

Inspecting the ERR value after the PostQueuedCompletionStatus() call in wxIOCPService::PostEmptyStatus() in include/wx/msw/private/fswatcher.h might also help.

By the way, have I already told you I believe wxFSW is not ready for deployment? ;)
By the way 2, does fswatcher sample exit without this error message when watching the same path as in your app?

MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid » Fri Mar 04, 2011 10:26 am

The trace output
(fswatcher) Posting empty status!
Der Thread 'Win32 Thread' (0xd1c) hat mit Code 0 (0x0) geendet.
(fswatcher) Deleting entry 'C:\Users\user\AppData\Roaming\wxCron'
The sample exit without any problems.

MoonKid
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 543
Joined: Wed Apr 05, 2006 9:39 am
Contact:

Post by MoonKid » Fri Mar 04, 2011 10:41 am

PB wrote:Inspecting the ERR value after the PostQueuedCompletionStatus() call in wxIOCPService::PostEmptyStatus() in include/wx/msw/private/fswatcher.h might also help.
This is '1'.

User avatar
doublemax
Moderator
Moderator
Posts: 13985
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Fri Mar 04, 2011 11:36 am

Yes I am using wxFileSystemWatcher class. And I do a delete on it in the dtor of my application class.
Maybe this is too late to destroy it. Try destoying it in wxApp::OnExit() or in the dtor of the mainframe (if your application has one).
Use the source, Luke!

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2020
Joined: Sun Jan 03, 2010 5:45 pm

Post by PB » Fri Mar 04, 2011 11:44 am

Ah, I overlooked that. As always doublemax saves the day. :D

User avatar
doublemax
Moderator
Moderator
Posts: 13985
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Fri Mar 04, 2011 11:58 am

Ah, I overlooked that. As always doublemax saves the day.
I'm not sure about that, was just an idea ;)
Use the source, Luke!

Post Reply