Page 1 of 1

ungraceful worker thread termination

Posted: Fri Mar 04, 2011 2:00 am
by MoonKid
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?

Posted: Fri Mar 04, 2011 6:43 am
by PB
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?

Posted: Fri Mar 04, 2011 9:01 am
by MoonKid
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?

Posted: Fri Mar 04, 2011 10:03 am
by PB
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?

Posted: Fri Mar 04, 2011 10:26 am
by MoonKid
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.

Posted: Fri Mar 04, 2011 10:41 am
by MoonKid
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'.

Posted: Fri Mar 04, 2011 11:36 am
by doublemax
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).

Posted: Fri Mar 04, 2011 11:44 am
by PB
Ah, I overlooked that. As always doublemax saves the day. :D

Posted: Fri Mar 04, 2011 11:58 am
by doublemax
Ah, I overlooked that. As always doublemax saves the day.
I'm not sure about that, was just an idea ;)