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; /// /// Gets the status if is executing. /// public bool Executing { get => _executing; private set => _executing = value; } public ExecutingStatus() { _executingEvent.Set(); Executing = false; } /// /// Reset the status. /// public void Reset() { _executingEvent.Reset(); Executing = true; } /// /// Set the status. /// public void Set() { Executing = false; _executingEvent.Set(); } /// /// Wait for the status to set. /// public void Wait() { _executingEvent.WaitOne(); } public void Wait(double secondsTimeout) { _executingEvent.WaitOne(TimeSpan.FromSeconds(secondsTimeout)); } } }