private static async Task TryToRun(WorkflowBuilder workflowBuilder) { if (_numberOfExceptionsInLastTime++ >= HOW_MANY_EXCEPTIONS_IN_SHORT_TIME_TO_STOP_BOT) { throw new Exception("Too many restarts"); } try { await workflowBuilder.Run(); } catch (Exception e) { HandleException(e); await Task.Delay(10000); } }