|
-
Apr 5th, 2010, 02:24 PM
#1
Thread Starter
Hyperactive Member
thread pausing
I am wondering if anyone has encountered a time in which they would pause a thread for longer than 60 seconds? Right now, when I pause a thread and let it go for longer than 60 seconds, it will cause a warning (something about pumping messages). I know I can just continue with the program, but I doubt it's really safe to keep doing this, and what happens when I release the application live without debugging?
Is there anyway around this, or is it ok to just leave it as is?
-
Apr 5th, 2010, 03:57 PM
#2
Re: thread pausing
If it is the UI thread, I'd say it is a problem. If not then try this
Code:
Dim stpw As New Stopwatch
Dim howLongToReallySleep As New TimeSpan(0, 1, 0) 'one minute
'where you have thread.sleep 60 secs. replace with
stpw.Reset() 'start the clock
stpw.Start()
Do
Try
Threading.Thread.Sleep(100)
Catch
End Try
Loop While stpw.Elapsed < howLongToReallySleep
-
Apr 5th, 2010, 09:14 PM
#3
Re: thread pausing
Why exactly are you sleeping a thread that long anyway? Normally the only reason you'd sleep for a long time is because you're waiting for something to happen. In that case though, you'd normally sleep for short periods of time and poll repeatedly to see if the thing you were waiting for had occurred. Otherwise you might be sleeping for a long time after you could have proceeded. That is generally best avoided too though. If you explain what you're actually trying to achieve then we can provide the best advice on how to achieve it.
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
|