public void Run() { Task.Run(() => { while (Thread.CurrentThread.IsAlive) { if (IsRunBlock) { Thread.Sleep(TimeSpan.FromSeconds(1)); continue; } var @event = GetNextEvent(stateStorage.GetState()); if (@event != null) { TryHandleEvent(@event); } } }); }