Cycle de progression Faire (quelque chose qui marche) -> comprendre ce que l’on fait/comment cela marche -> pousser plus loin les notions
| public class PollTimer :IDisposable { private System.Threading.Timer timer; public void StartPolling(TimerCallback callbackMethod, int period) { if (callbackMethod == null) throw new ArgumentNullException("callbackMethod"); if (period <= 0) throw new Exception("period"); timer = new System.Threading.Timer(callbackMethod, null, 1000, period); } public void StopPolling() { if (timer == null) throw new InvalidOperationException(""); Dispose(); } #region IDisposable Membres public void Dispose() { timer.Dispose(); timer = null; } #endregion } |
| PollTimer pollTimer = new PollTimer(); private void button1_Click(object sender, EventArgs e) { pollTimer.StartPolling(Message, 1000); } public void Message(object obj) { MessageBox.Show("now"); } |