comparison Implab/Components/RunnableComponent.cs @ 252:6f4630d0bcd9 v3

removed absolete Diagnostics classes
author cin
date Mon, 12 Feb 2018 07:24:31 +0300
parents 7c7e9ad6fe4a
children c52691faaf21
comparison
equal deleted inserted replaced
251:7c7e9ad6fe4a 252:6f4630d0bcd9
13 /// termination of the component. 13 /// termination of the component.
14 /// </remarks> 14 /// </remarks>
15 public class RunnableComponent : IRunnable, IInitializable, IDisposable { 15 public class RunnableComponent : IRunnable, IInitializable, IDisposable {
16 16
17 /// <summary> 17 /// <summary>
18 /// This class bound <see cref="CancellationTokenSource"/> lifetime to the task, 18 /// This class bounds <see cref="CancellationTokenSource"/> lifetime to the task,
19 /// when the task completes the associated token source will be disposed. 19 /// when the task completes the associated token source will be disposed.
20 /// </summary> 20 /// </summary>
21 class AsyncOperationDescriptor { 21 class AsyncOperationDescriptor {
22 22
23 public static AsyncOperationDescriptor None { get; } = new AsyncOperationDescriptor(); 23 public static AsyncOperationDescriptor None { get; } = new AsyncOperationDescriptor();
159 /// </summary> 159 /// </summary>
160 /// <param name="ct">A cancellation token for this operation</param> 160 /// <param name="ct">A cancellation token for this operation</param>
161 /// <remarks> 161 /// <remarks>
162 /// This method should be used for short and mostly syncronous operations, 162 /// This method should be used for short and mostly syncronous operations,
163 /// other operations which require time to run shoud be placed in 163 /// other operations which require time to run shoud be placed in
164 /// <see cref="StartInternal(CancellationToken)"/> method. 164 /// <see cref="StartInternalAsync(CancellationToken)"/> method.
165 /// </remarks> 165 /// </remarks>
166 protected virtual Task InitializeInternalAsync(CancellationToken ct) { 166 protected virtual Task InitializeInternalAsync(CancellationToken ct) {
167 return Task.CompletedTask; 167 return Task.CompletedTask;
168 } 168 }
169 169
170 public void Start(CancellationToken ct) { 170 public void Start(CancellationToken ct) {
171 var cookie = new object(); 171 var cookie = new object();
172 if (MoveStart(cookie)) 172 if (MoveStart(cookie))
173 ScheduleTask(StartInternal, ct, cookie); 173 ScheduleTask(StartInternalAsync, ct, cookie);
174 } 174 }
175 175
176 protected virtual Task StartInternal(CancellationToken ct) { 176 protected virtual Task StartInternalAsync(CancellationToken ct) {
177 return Task.CompletedTask; 177 return Task.CompletedTask;
178 } 178 }
179 179
180 public void Stop(CancellationToken ct) { 180 public void Stop(CancellationToken ct) {
181 var cookie = new object(); 181 var cookie = new object();