comparison Implab/Components/PollingComponent.cs @ 260:547a2fc0d93e v3 v3.0.6

minor fixes
author cin
date Fri, 13 Apr 2018 19:14:59 +0300
parents 7d52dc684bbd
children f1696cdc3d7a
comparison
equal deleted inserted replaced
259:7d52dc684bbd 260:547a2fc0d93e
48 // component in Stopping state, no new polls will be scheduled 48 // component in Stopping state, no new polls will be scheduled
49 m_cancellation.Cancel(); 49 m_cancellation.Cancel();
50 try { 50 try {
51 // await for pending poll 51 // await for pending poll
52 await m_poll; 52 await m_poll;
53 } catch (OperationCanceledException e) { 53 } catch (OperationCanceledException) {
54 // OK 54 // OK
55 } 55 }
56 } 56 }
57 57
58 protected abstract Task Poll(CancellationToken ct); 58 protected abstract Task Poll(CancellationToken ct);
69 69
70 async void OnTimer(object state) { 70 async void OnTimer(object state) {
71 try { 71 try {
72 m_pending.Start(); 72 m_pending.Start();
73 await m_poll; 73 await m_poll;
74 ScheduleNextPoll(Interval);
74 } catch (Exception e) { 75 } catch (Exception e) {
75 UnhandledException.DispatchEvent(this, new UnhandledExceptionEventArgs(e, false)); 76 UnhandledException.DispatchEvent(this, new UnhandledExceptionEventArgs(e, false));
77
76 if (FailOnError) 78 if (FailOnError)
77 Fail(e); 79 Fail(e);
80 else
81 ScheduleNextPoll(Interval);
78 } 82 }
79 ScheduleNextPoll(Interval); 83
80 } 84 }
81 85
82 protected override void Dispose(bool disposing) { 86 protected override void Dispose(bool disposing) {
83 if (disposing) 87 if (disposing)
84 Safe.Dispose(m_timer, m_cancellation); 88 Safe.Dispose(m_timer, m_cancellation);