##// END OF EJS Templates
PollingComponent: implemented correct stopping
PollingComponent: implemented correct stopping

File last commit:

r259:7d52dc684bbd v3
r259:7d52dc684bbd v3
Show More
RunnableComponentTests.cs
42 lines | 1019 B | text/x-csharp | CSharpLexer
/ Implab.Test / RunnableComponentTests.cs
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);
}
}
}
}