260
|
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) {
|
262
|
24 await base.StopInternalAsync(ct);
|
260
|
25 if (StopWorker != null)
|
|
26 await StopWorker.Invoke(ct);
|
|
27 }
|
|
28
|
|
29 protected async override Task StartInternalAsync(CancellationToken ct) {
|
262
|
30 await base.StartInternalAsync(ct);
|
260
|
31 if (StartWorker != null)
|
|
32 await StartWorker.Invoke(ct);
|
|
33 }
|
|
34
|
|
35
|
|
36 }
|
|
37 } |