Re: DoEvents() "Hangs"



Don't sleep on the UI thread. Ever. You're preventing the UI
thread from processing any messages for 1 second. Disable the main form
and its controls or launch another simple modal form to actually launch
the processing thread and display some sort of "I'm running" indicator
until it receives notification (not by polling, by callback) that the
thread has finished.
Your implementation is broken, not the framework. This is not meant
to be snarky, just straightforward.

cedmunds@xxxxxxx wrote:
Exactly, I am using the BackgroundWorker (see code snippets) above. In
essence, I am firing off the stored proc and then putting the GUI in a
loop that sleeps for a while, awakens, and updates itself and then goes
back to sleep. This continues until the stored proc returns.

But the trouble is that it (the SleepAndUpdate loop) stops working
after a while. When it first fires up, everything is great and then
after an indeterminate period of time the DoEvents() stops returning.

It is puzzling.

I hate to take the "easy" way out and point to the framework but that
is indeed what it seems like the trouble is.

All helpful thoughts and suggestions (not the snarky ones about "Do
people really still use DoEvents() (is it even valid in C#?).") are
appreciated.

wfairl@xxxxxxxxx wrote:
Then you need to just disable the GUI programmitically. Thread.Sleep()
on the UI thread is never correct. Look into using the BackgroundWorker
class for a simple and sound solution if you're using 2.0.

http://msdn2.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx


.



Relevant Pages

  • Re: I feel like I am dying
    ... although I did not think I would sleep 18 hours from it. ... > trouble I have been having lately! ... > people alike and no two with symptoms will be the same}....but if I am ... > that having trouble sleeping and Fibro. ...
    (alt.med.fibromyalgia)
  • Re: Persias Confused
    ... I'm not going to (as one friend put it) "take to my bed". ... If you fall asleep in the living room, you have to get up and go to bed when you wake up, and may have trouble getting back to sleep. ...
    (rec.pets.cats.anecdotes)
  • Re: OT: Wilma Wow!
    ... >Have you managed to get clear through the game yet? ... PopCap has several ... I had trouble going to sleep last night because every ...
    (rec.crafts.textiles.needlework)
  • Re: GMT Thursday 11th September
    ... little more promising. ... Trouble is I couldn't go back to sleep for the ows so I had to repair to the kitchen and feed myself some PKs. ... Good morning Pam, I hope you were able to get back to bed and more sleep. ...
    (uk.people.silversurfers)
  • Re: DoEvents() "Hangs"
    ... loop that sleeps for a while, awakens, and updates itself and then goes ... But the trouble is that it stops working ... after an indeterminate period of time the DoEvents() stops returning. ...
    (microsoft.public.dotnet.languages.csharp)