private void Execute(ICommand command, Message message) { if (Settings.MaximumThreadsForCommands > 0 && _threads >= Settings.MaximumThreadsForCommands) { while (_threads <= Settings.MaximumThreadsForCommands) { // Wait, when we can go to execute command } } Task.Factory.StartNew(() => { try { _threads++; command.Executed(message); } catch (Exception exc) { if (Settings.ExceptionsToConsole) { Telesharp.Logger.Log(LogType.Error, Settings.Name, $"Exception, when execute command:\n{exc}"); } } finally { _threads--; } }); }
private void ExecuteSync(ICommand command, Message message) { try { // Execute command command.Executed(message); } catch (Exception exc) { if (Settings.ExceptionsToConsole) { Telesharp.Logger.Log(LogType.Error, Settings.Name, $"Exception, when execute command:\n{exc}"); } } }
private void ExecuteSync(ICommand command, Message message) { try { // Execute command command.Executed(message); } catch (Exception exc) { if (Settings.ExceptionsToConsole) Telesharp.Logger.Log(LogType.Error, Settings.Name, $"Exception, when execute command:\n{exc}"); } }
private void Execute(ICommand command, Message message) { if (Settings.MaximumThreadsForCommands > 0 && _threads >= Settings.MaximumThreadsForCommands) { while (_threads <= Settings.MaximumThreadsForCommands) { // Wait, when we can go to execute command } } Task.Factory.StartNew(() => { try { _threads++; command.Executed(message); } catch (Exception exc) { if (Settings.ExceptionsToConsole) Telesharp.Logger.Log(LogType.Error, Settings.Name, $"Exception, when execute command:\n{exc}"); } finally { _threads--; } }); }