Reputation: 99
I do have one function to update my UI: At the moment i call this function more than 8 times in my Action function that will update my UI
public void CheckStatus()
{
this.ovl_stacker1.FillColor =
OvalShape == MEssage.EMPTY ? Color.Red :
OvalShape == Message.WARNING ? Color.Yellow : Color.Green;
this.OvalShape .Refresh();
}
how can i make this function Auto Run every 5 Sec on my main? ( because i dont want to call the function in other functions many times)
Here is my ActionFunction
public void Action()
{
//do something....
checkstatus();
//do something.......
checkstatus();
//do something........
checkstatus();
...
...
..
}
Upvotes: 0
Views: 137
Reputation: 244757
To call a method every 5 seconds, you could use a timer, but I don't think that's the right solution here. (Although, for a timer to work, you would also need to have the UI thread idle, which it seems you don't.)
Instead, you should call CheckStatus()
when you actually change the status, ideally in a setter of the relevant property.
Upvotes: 3