Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am working on a windows application.

I need one of my forms to be refreshed every 60 seconds.
I know this can be implemented through a thread but I am not finding a way.
Really appreciate if anyone could provide me with a sample code.

Thanks in advance!
Posted
Updated 29-Jun-17 19:54pm
v2
Comments
Dalek Dave 16-Jun-11 3:10am    
Edited for Grammar and Readability.

Why a thread? If you really need this to occur, set up a class level Timer, with an interval of 60 Seconds, and do the refresh in the Tick event.

Timer refreshTimer = new Timer();
...
         refreshTimer.Interval = 60000;  //60 seconds in milliseconds
         refreshTimer.Tick += new EventHandler(refreshTimer_Tick);
         refreshTimer.Start();
...
     void refreshTimer_Tick(object sender, EventArgs e)
         {
         Invalidate();
         }
 
Share this answer
 
Comments
Dalek Dave 16-Jun-11 3:11am    
Spot on, A timer is the way it is.
Take a Timer Control after that
on the form load
{....
timer1.Interval = 60000;
timer1.Start();
}
creat a variable = static int t1 = 0;
On timer tick event
private void timer1_Tick(object sender, EventArgs e)
{
if (t1 == 0)
{
// Go Update anything
t1 = 1;
}
else
{
// Go update anything<
t1 = 0;
}

}
 
Share this answer
 
Comments
Patrice T 30-Jun-17 3:32am    
6 years too late.
TheRealSteveJudge 30-Jun-17 3:59am    
Hope the questioner still can remember the asked question.
Mohsin Afzal 15-Feb-18 1:55am    
hahahahah

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900