comparison Implab.Test/MockPollComponent.cs @ 260:547a2fc0d93e v3 v3.0.6

minor fixes
author cin
date Fri, 13 Apr 2018 19:14:59 +0300
parents
children f1696cdc3d7a
comparison
equal deleted inserted replaced
259:7d52dc684bbd 260:547a2fc0d93e
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
4 using Implab.Components;
5
6 namespace Implab.Test {
7 public class MockPollComponent : PollingComponent {
8
9 public Func<CancellationToken,Task> PollWorker { get; set;}
10
11 public Func<CancellationToken, Task> StartWorker { get; set; }
12
13 public Func<CancellationToken, Task> StopWorker { get; set; }
14
15 public MockPollComponent(bool initialized) : base(initialized) {
16 }
17
18 protected async override Task Poll(CancellationToken ct) {
19 if(PollWorker!= null)
20 await PollWorker.Invoke(ct);
21 }
22
23 protected async override Task StopInternalAsync(CancellationToken ct) {
24 if (StopWorker != null)
25 await StopWorker.Invoke(ct);
26 }
27
28 protected async override Task StartInternalAsync(CancellationToken ct) {
29 if (StartWorker != null)
30 await StartWorker.Invoke(ct);
31 }
32
33
34 }
35 }