Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: "OZI" <sql_agentman@xxxxxxxxxxx>
- Date: Thu, 13 Sep 2007 12:06:55 -0700
Peter,
Fair enough. I created a New Test Form with One Button and One progressBar.
See Button Event Below.
When I click on the button and Drag the Form ( try hard to drag it ), then
No Progress is shown, also if you drag it and click anywhere on the Form you
see the No Response in the title of the Form.
There is no intensive Processing here. How can this be explained?
private void button1_Click(object sender, EventArgs e)
{
progressBar1.Maximum = 10;
progressBar1.Minimum = 0;
progressBar1.Value = 0;
progressBar1.Visible = true;
progressBar1.Show();
this.Refresh();
for (int x = 0; x < progressBar1.Maximum ; x++)
{
progressBar1.Increment(1);
System.Threading.Thread.Sleep(1000);
this.Refresh();
}
progressBar1.Visible = false;
progressBar1.Value = 0;
}
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:13ej0lngnj5ih10@xxxxxxxxxxxxxxxxxxxxx
OZI wrote:
Can you give me an explanation why when I drag my Form it goes into a
Non-Responding "Mode".
When I click my Process Button, Not touch anything, just sit there and
watch it, everything works fine, My progress Bar is updating and showing
the Progress until the Form is moved or loses it focus.
It would be difficult to explain why you get some updating even when the
processing is in the same thread as the UI, unless you can post a
concise-but-complete example of code that demonstrates that behavior.
Suffice to say, however, that lengthy processing should not be in the same
thread that owns your UI objects, whether it works some of the time or
not.
Also can you please direct me to an example of how to create, use, and
update the UI from another "Worker" Thread.
Both Chris and I have mentioned the BackgroundWorker class. You should
start by looking at the MSDN documentation for that class, as well as
searching this newsgroup for other threads that discuss the class. There
is already a lot of information out there explaining how it's used.
If after reading that information you still have questions then of course,
please post the specific questions concerned any specific issues you run
into.
Pete
.
- Follow-Ups:
- Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- From: Ian Semmel
- 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
- 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
- Simple WinForm ( Not Responding ) Refesh Issue C# 2.0
- Prev by Date: User Control Datasource
- Next by Date: Re: How to reassign event handler at runtime
- 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):