|
-
Sep 19th, 2012, 02:50 PM
#1
Pausing Background Thread Until Operation Completes
I'm launching a background thread and running a task in that thread that takes about an hour. That task must complete before the thread continues. So I'm pausing it by calling Application.DoEvents until the method returns a value. I'm not a big fan of Application.DoEvents though.
So is there a better method to accomplish this task?
Thanks
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Sep 19th, 2012, 03:15 PM
#2
Re: Pausing Background Thread Until Operation Completes
Something in that statement isn't parsing for me. Does the background thread launch another thread for the task? Is the task a different process?
I'm not so keen on DoEvents, either, though sometimes it is the best solution. From what I think I understand about the question, the thread that has to wait is not the UI thread, so it can sit and do nothing without anybody noticing or caring. That would be possible if the task was a blocking one, such that you called it, then execution on that thread stopped until the task returned, or it would be possible if the task could raise an event. The former is better than the latter, in some regards, but either would work. If the task doesn't block, and doesn't raise an event, then there may be no very good solution. Spin waiting would be the worst solution, though, so avoid doing that.
My usual boring signature: Nothing
 
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
|