public static void Do_ThreadSleepN(bool burn) { var cts = new CancellationTokenSource(); new Thread(() => Worker(cts.Token)).Start(); if (burn) { CpuBurner.Fire(cts.Token); } Wait_PressEnterToStop(); cts.Cancel(); }
public static void Do_DedicatedThreadStopwatch(bool burn) { var cts = new CancellationTokenSource(); new Thread(() => SwatchedWorker(cts.Token)).Start(); if (burn) { CpuBurner.Fire(cts.Token); } Wait_PressEnterToStop(); cts.Cancel(); }
public static void Do_ThreadingTimer(int interval, bool burn) { var cts = new CancellationTokenSource(); var timer = new System.Threading.Timer((o) => DoTick(), null, 1000, interval); if (burn) { CpuBurner.Fire(cts.Token); } Wait_PressEnterToStop(); cts.Cancel(); timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); timer.Dispose(); }
public static void Do_TimersTimer(double interval, bool burn) { var cts = new CancellationTokenSource(); var timer = new System.Timers.Timer(interval); timer.Elapsed += (s, e) => DoTick(); timer.Start(); if (burn) { CpuBurner.Fire(cts.Token); } Wait_PressEnterToStop(); cts.Cancel(); timer.Stop(); }
public static void Do_TwincatNotification(bool burn) { var cts = new CancellationTokenSource(); AdsClient client = new AdsClient(); client.Connect(AmsPort.R0_RTS + 1); client.AdsNotification += (s, e) => DoTick(); var notiSets = new NotificationSettings(AdsTransMode.OnChange, 1, 0); var h_tick = client.AddDeviceNotification("MAIN.tick", 1, notiSets, null); if (burn) { CpuBurner.Fire(cts.Token); } Wait_PressEnterToStop(); cts.Cancel(); client.DeleteDeviceNotification(h_tick); client.Disconnect(); }
public static void Do_MultimediaTimer(int interval, bool burn) { var cts = new CancellationTokenSource(); var mTimer = new MultimediaTimer() { Interval = interval, Resolution = 0 // ms, maximum possible resolution = 0 }; mTimer.Elapsed += (s, e) => DoTick(); mTimer.Start(); if (burn) { CpuBurner.Fire(cts.Token); } Wait_PressEnterToStop(); cts.Cancel(); mTimer.Stop(); }