DoEvents causes form to hang

  • Thread starter Thread starter kahwon t via DotNetMonster.com
  • Start date Start date
K

kahwon t via DotNetMonster.com

SORRY I ACCIDENTALLY POSTED THIS IN THE WinForm Controls SECTION:

I can not figure out for the life of me why my app / form hangs afte I do a
show:

Me.Show()
While Not Done

System.Windows.Forms.Application.DoEvents()

End While

To test it, I threw a me.refresh in to see what was going on and when I ran
my code, I could work on the form for about 5 - 10 seconds before it hung.

Is there someone who might be able to help me?? this is an app that was
converted from vb6 to vb.net using the conversion tool.
 
kahwon t via DotNetMonster.com said:
SORRY I ACCIDENTALLY POSTED THIS IN THE WinForm Controls SECTION:

I can not figure out for the life of me why my app / form hangs afte I do a
show:

Me.Show()
While Not Done

System.Windows.Forms.Application.DoEvents()

End While

To test it, I threw a me.refresh in to see what was going on and when I ran
my code, I could work on the form for about 5 - 10 seconds before it hung.

Is there someone who might be able to help me?? this is an app that was
converted from vb6 to vb.net using the conversion tool.

Well, whatever's actually happening, using Application.DoEvents like
that seems like a pretty bad idea to me. Why not just let the message
pump do its work in the normal way?
 
That may be. The DoEvents is a holdover from the conversion. I was able to
get some relief by throwing in a thread.sleep(10) in the loop but when I go
to do a form.close now it appears to hang just like when I did a form.show.
It is becoming apparent to me that there is something I am missing here but
no knowledge article or book that I've looked in has been able to tell me
anything I need to fix this.......HELP!!!!!
SORRY I ACCIDENTALLY POSTED THIS IN THE WinForm Controls SECTION:
[quoted text clipped - 13 lines]
Is there someone who might be able to help me?? this is an app that was
converted from vb6 to vb.net using the conversion tool.

Well, whatever's actually happening, using Application.DoEvents like
that seems like a pretty bad idea to me. Why not just let the message
pump do its work in the normal way?
 
kahwon t via DotNetMonster.com said:
That may be. The DoEvents is a holdover from the conversion. I was able to
get some relief by throwing in a thread.sleep(10) in the loop but when I go
to do a form.close now it appears to hang just like when I did a form.show.
It is becoming apparent to me that there is something I am missing here but
no knowledge article or book that I've looked in has been able to tell me
anything I need to fix this.......HELP!!!!!

It's definitely worth getting rid of the loop - it shouldn't be there
in the first place. You should just let the UI thread "do its thing"
and exit at the appropriate time.
 
Back
Top