|
-
Sep 5th, 2004, 01:56 PM
#1
Thread Starter
Frenzied Member
Do I need Control.Invoke()?
I'm wondering if this code is ok or if maybe I should be doing Control.Invoke(). Not that I know how to do .Invoke. The code seems to run just fine.
Code:
private void btnLogon_Click(object sender, System.EventArgs e)
{
Thread t = new Thread(new ThreadStart(IncrementProgressBar));
t.Start();
.
.
.
private void IncrementProgressBar()
{
do
{
if (progressBar1.Value >= 95)
{
progressBar1.Value = 0;
}
progressBar1.Value += 5;
Thread.Sleep(250);
}
while (true);
}
I thought there was a trick with modifying a control from a different thread, but not sure if you only need to do that with a method and not a property.
Thanks,
Mike
-
Sep 5th, 2004, 05:14 PM
#2
PowerPoster
You should be using invoke if you are talking accross threads. This is a weird one cause it is miss-leading. Windows XP has a "feature" that allows this to work, yet, from everywhere I have heard this, the other OS's don't allow you to do it. So if your code was running on a different OS, you might have some problems. You might want to do some good testing.
-
Sep 5th, 2004, 08:23 PM
#3
Thread Starter
Frenzied Member
ok. Any idea how one would write that code using .Invoke? I've searched and read, but don't quite get it.
Mike
-
Sep 5th, 2004, 11:12 PM
#4
PowerPoster
-
Sep 6th, 2004, 11:00 AM
#5
Thread Starter
Frenzied Member
Thanks for the links. Need to get my head around all the delegate stuff. Thanks.
Mike
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
|