|
-
November 6th, 2010, 04:05 AM
#1
Trying to resolve a locking thread
I know that this question may sound quite vague but I don't know how else to address it. I have a process with several worker threads. When the process is closing I need to gracefully shut it down. I use a well established and tried mechanism of a signaling "stop event" to let all worker threads know that it's time to quit, while at the same time waiting for all thread handles to become signaled.
Here's the code for the waiting part:
Code:
//Signal threads that it's time to stop
SetEvent(hEventStopNow);
//And wait for all threads to be signaled
DWORD dwR = WaitForMultipleObjects(nThreadCount, pThreadHandles, TRUE, 5000);
Most times the waiting API above returns almost immediately, but maybe 1% of the times it does not and times out with error code 258. The situation is made worse by the following factors:
1. The process in question is a screen saver
2. And it is running on a client's machine that I don't have access to.
The worker threads are:
A. One that does graphics rendering using GDI+
B. Then another thread that preps graphics for the thread A
(The access to these objects are synchronized between threads using mutexes)
OK, now my question. Is there any way to find out where a thread is locked up when or after a waiting API times out, or which API was called in it last?
PS. Please note that I'm not asking to check if my process of synchronization between threads is correct, I've done that many times myself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|