0

Hey All,

Threading may not be the answer to this, but here's my current situation.

I have a form that I want updated about every 5 seconds. I couldn't figure out how to do this, so I just did a refresh on a button click on that form. However, in order to do this, I have to create an entire new instance of that form, close the old one, and then show the new one.

private void buttonRefresh_Click(object sender, System.EventArgs e) 
{            
Status stat = new Status(...);            
this.Close();            
stat.Show();        
}

So while this works, there are probably better solutions, but i basically just want it to update every 5 seconds.

Thanks,
-Mario

2
Contributors
9
Replies
10
Views
9 Years
Discussion Span
Last Post by iamthwee
0

The form that i need to refresh displays a bunch of information read in and displays it in different labels/textboxes on the on the form.

0

Are you saying you just need to clear text field then update them with new information?

If that's the case can't you just do.

TextBox1.Text = "";
0

yes i can do that, but how do i automate that process with a timer?

im trying to avoid the button press to refresh.

0

I'm assuming it would be the same as always.

Every five seconds run code
  TextBox1.Text = "":
  TextBox2.Text = "";
  TextBoxn.Text = "";

yada yada yada...?

0

which brings me back to my original question:

I don't know how to use a timer like that. How to set up a method or block of code to be ran every 5 seconds. It would obviously have to be on a separate thread, which i also do not understand how to do :)

0

Maybe I'm missing something but isn't there a time elapsed function in the timer class.

Then you can keep track of the time. When it hits every five seconds ( i.e perform a modulus five = 0 or something similar) then run the code to reset the text fields? I'm not sure how useful the below links are. I looked at them briefly. I don't think you need a time controlling function on a separate thread/form.

http://www.developer.com/lang/other/article.php/792901

http://www.csharphelp.com/archives/archive90.html

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.