.NET 4.x Создать Custom Awaiter - C#
Формулировка задачи:
Здраствуйте, нужна помощь в создании custom awaiter'а:
Задача:
Не доходит как реализовать =)
Листинг программы
- class CustomAwaiter : INotifyCompletion
- {
- private Action _continuation;
- public CustomAwaiter()
- {
- IsCompleted = false;
- }
- public bool IsCompleted { get; private set; }
- public void GetResult()
- {
- }
- public void Complete()
- {
- if (_continuation != null)
- {
- _continuation();
- IsCompleted = true;
- }
- }
- public void OnCompleted(Action continuation)
- {
- _continuation += continuation;
- }
- }
-Create an awaiter that will allow awaiting on a integer. The integer represents the amount of miliseconds to delay.
-Create a custom awaiter that will allow awaiting on a process and continue when the process exit.
Решение задачи: «.NET 4.x Создать Custom Awaiter»
textual
Листинг программы
- EventWaitHandle waitHandle = new AutoResetEvent(false);
- waitHandle.WaitOne(3000);
- waitHandle.Set();
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д