wpf first time, refresh this page to the timing, I also took the boss's effort, heaven pays off, finally to get it out, man of few words said, directly on the code.
// Timer private System.Timers.Timer timerNotice = null;
// timed refresh the page
private void TimeRefresh_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
double countTime = 0; string timeStr = this.TimeRefreshRCB.SelectionBoxItem.ToString();
if ( "turn off the automatic refresh" .Equals (timeStr))
{
if (timerNotice! = null) {timerNotice.Stop ();
picTour.time.Visibility = Visibility.Hidden;
}
}
if ("开启".Equals(timeStr))
{
if (timerNotice != null)
{
timerNotice.Stop ();
}
countTime = 60 * 60 * 1000;
timerNotice = null;
picTour.time.Visibility = Visibility.Visible;
}
if (! "turn off the automatic refresh" .Equals (timeStr) && timerNotice == null)
{
QueryData();
timerNotice System.Timers.Timer = new ();
picTour.PicDate2.DateTimeText = staticVar.showTime.ToString();
timerNotice.Elapsed += new System.Timers.ElapsedEventHandler((o, eea) =>
{
QueryData();
});
timerNotice.Interval COUNT = hour; timerNotice.Start ();
}
}
In fact, the code is not difficult to write, think of a more complex process, QueryData () method to execute a query page data, needs to be emphasized here QueryData () must be a static method, TimeRefresh_SelectionChanged () is a RadComboBox selection drop-down box, you can select periodically refresh interval.