-
March 30th, 2010, 04:15 AM
#1
Threading Question.
Hello, I am fairly new to the concept of threading in C++ but I am giving it a go and trying to create a thread class. Creating a thread is easy enough with _beginthreadex. But I have hit a wall. So far my class is quite simple it. The constructor takes a "this" pointer ans uses it to pass to the thread routine which casts it back to the correct class type and executes a long running method while a progress bar informs the user. All very simple. I am using RegisterWaitForSingleObject to initiate a callback routine that stops the progress bar after the thread has finished it's job. Here is the problem. Where do I call UnregisterWait? The main thread has moved on and there's no way for it to know when the worker thread has finished, and i'm not allowed (according to MSDN) to call UnregisterWait from inside the CallBack Routine. So where is it supposed to be called? The Callback routine is the only method that knows when the thread has completed it's work. Help! :-)
-
March 31st, 2010, 08:16 AM
#2
Re: Threading Question.
Maybe a solution might be to send a custom WM_APP message to your main window. Then when the main window receives this WM_APP message, it can call the UnregisterWait.
-
April 3rd, 2010, 09:31 AM
#3
Re: Threading Question.
concept of threading in C++
Sorry but there's no such a concept. C++ is indifferent to threading of any nature.
Best regards,
Igor
-
April 6th, 2010, 09:59 PM
#4
Re: Threading Question.
You wrote: ... The main thread has moved on and there's no way for it to know when the worker thread has finished...
- you can WaitForSingleObject(<worker theread>) in the main thread to get the worker theread's state.
-
April 7th, 2010, 04:34 PM
#5
Re: Threading Question.
Let me answer with a different question: What is the need of calling 'RegisterWaitFor SingleObject()' in the first place?
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
|