Example #1
0
 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--;
         }
     });
 }
Example #2
0
 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}");
         }
     }
 }
Example #3
0
		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}");
			}
		}
Example #4
0
		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--;
				}
			});
		}