123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Threading;
- namespace Flyinsono.Client.Test.Utilities.Executors
- {
- public class ExecutingStatus
- {
- private readonly ManualResetEvent _executingEvent = new ManualResetEvent(true);
- private volatile bool _executing;
- /// <summary>
- /// Gets the status if is executing.
- /// </summary>
- public bool Executing
- {
- get => _executing;
- private set => _executing = value;
- }
- public ExecutingStatus()
- {
- _executingEvent.Set();
- Executing = false;
- }
- /// <summary>
- /// Reset the status.
- /// </summary>
- public void Reset()
- {
- _executingEvent.Reset();
- Executing = true;
- }
- /// <summary>
- /// Set the status.
- /// </summary>
- public void Set()
- {
- Executing = false;
- _executingEvent.Set();
- }
- /// <summary>
- /// Wait for the status to set.
- /// </summary>
- public void Wait()
- {
- _executingEvent.WaitOne();
- }
- public void Wait(double secondsTimeout)
- {
- _executingEvent.WaitOne(TimeSpan.FromSeconds(secondsTimeout));
- }
- }
- }
|