[[tinyclros:accueiltinyclr|{{ :iconemaison.jpg?nolink&25|Sommaire TinyCLR}}]] ==== La gestion du temps (Timer, HTR) ==== ** Rédacteur** : Philippe Mariano {{ :tinyclros:gpio:tinyclros.png?nolink&80|}} [Mise à jour le 8/4/2020] === 1. Timer === En cours de rédaction static void Ticker(object o) { Debug.WriteLine("Hello!"); } static void Main() { Timer timer = new Timer(Ticker, null, 3000, 1000); Thread.Sleep(Timeout.Infinite); } === 2. Horloge Temps Réel HTR ( ou RTC) === //"Une horloge temps réel (terme parfois abrégé en HTR, en anglais real-time clock ou RTC), est une horloge permettant un décompte très précis du temps (par exemple en nanosecondes) pour un système électronique, en vue de dater ou déclencher des évènements selon l'heure".// Wikipédia * **Exemple** testé sur une carte [[tinyclros:tclr_code_panda3|Panda 3]] using GHIElectronics.TinyCLR.Devices.Rtc; using System; using System.Diagnostics; using System.Threading; class Program { static void Main() { var rtc = RtcController.GetDefault(); rtc.Now = new DateTime(2019, 1, 8, 9, 0, 0); while (true) { Debug.WriteLine(rtc.Now.ToString()); Thread.Sleep(1000); } } }