Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: "OZI" <sql_agentman@xxxxxxxxxxx>
- Date: Thu, 13 Sep 2007 15:19:58 -0700
Morten,
Thank you so much it is somewhat clearer for me know.
OZI
"Morten Wennevik [C# MVP]" <MortenWennevik@xxxxxxxxxxx> wrote in message
news:op.tyl0qri2dj93y5@xxxxxxxx
On Thu, 13 Sep 2007 22:15:52 +0200, OZI <sql_agentman@xxxxxxxxxxx> wrote:
Morten,
Application.DoEvents() did everything I need.
You are right I don't need the Refresh();
However, I wish I understand what does that mean. I need help
understanding what does Application.DoEvents() mean and why it solved my
Problem.
I will also look into the BackgroundWorker solution, As soon as I have
time
and the "big cheese" goes invisible, I think that would be best on the
long
run?
Thank you so much for your help.
OZI
Windows is event driven, which all the little things you see on the user
interface is done by firing a whole bunch of various events. However, a
regular application is also single threaded, which means executing event
handling has to compete with regular code. This works fine in most cases
where methods do not do much and is executed within a second or less,
which means, if you click a button right after you start a method, the
button click might event might not get handled until the one second method
is done processing. This becomes very noticeably when the method takes a
lot more than one second, making the user interface appear sluggish or non
responsive as everything the user does to the interface creates a queue of
waiting events (Windows discards windows events that aren't processed
within a certain timelimit so the click might not execute at all). This
queue will be processed when your method is finished processing.
Application.DoEvents() pauses your method and lets the
application process any waiting events, and will continue the method when
the events are processed. Calling Application.DoEvents every so often
(several times per second) will keep the GUI responsive, and is very handy
in a simple loop where each turn does not take much time. If each turn
takes too long you need to put the entire loop in a separate thread, which
is were the BackgroundWorker comes into play.
--
Happy coding!
Morten Wennevik [C# MVP]
.
- References:
- Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: OZI
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: Chris Shepherd
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: OZI
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: Peter Duniho
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: OZI
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: Morten Wennevik [C# MVP]
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: OZI
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: Morten Wennevik [C# MVP]
- Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- Prev by Date: Re: DataSet Usage
- Next by Date: Re: DataGridView Disappears
- Previous by thread: Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- Next by thread: Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- Index(es):