thể trùng lặp:
Synchronizing a timer to prevent overlapLàm thế nào để tạm dừng một Threading.timer để hoàn thành một chức năng
Tôi có một Threading.Timer
trong lớp học của tôi.
System.Threading.Timer timer;
TimerCallback cb = new TimerCallback(ProcessTimerEvent);
timer = new Timer(cb, reset, 1000, Convert.ToInt64(this.Interval.TotalSeconds));
và xác định gọi lại cho nó.
private void ProcessTimerEvent(object obj)
{
if(value)
MyFunction();
}
Khi chạy, hãy chạy lại cuộc gọi trước myfunction
để hoàn tất.
Cách tạm dừng Threading.Timer
để hoàn tất myfunction
?
Tôi nghĩ bạn muốn ngăn [chồng chéo hẹn giờ] (http://stackoverflow.com/questions/684200/synchronizing-a-timer-to-prevent-overlap). –