using System; using System.Threading; using System.Threading.Tasks; using Implab.Components; using Xunit; namespace Implab.Test { class TimeLog : PollingComponent { public TimeLog() : base(true) { } protected override Task Poll(CancellationToken ct) { Console.WriteLine("Poll"); return Task.CompletedTask; } } public class UnitTest1 { [Fact] public async Task Test1() { using(var tl = new TimeLog()) { tl.StateChanged += (self, args) => Console.WriteLine("{0}", args.State); tl.Delay = 1000; tl.Interval = 500; tl.Start(CancellationToken.None); await tl.Completion; await Task.Delay(2000); tl.Stop(CancellationToken.None); await tl.Completion; await Task.Delay(3000); } } } }