public MtResponse SendCommand(MtCommand command) { Log.DebugFormat("SendCommand: begin. command {0}", command); if (command == null) { Log.Warn("SendCommand: end. command is not defined"); return(null); } var task = _executorManager.SendCommand(command); //wait for execute command in MetaTrader MtResponse response = null; try { response = task.WaitResult(WaitResponseTime); } catch (Exception ex) { Log.WarnFormat("SendCommand: Exception - {0}", ex.Message); } Log.DebugFormat("SendCommand: end. response = {0}", response); return(response); }
public MtResponse SendCommand(MtCommand command) { MtResponse response = null; if (command != null) { EventWaitHandle responseWaiter = new AutoResetEvent(false); lock (mResponseLocker) { mResponseWaiters[command] = responseWaiter; } mExecutorManager.EnqueueCommand(command); //wait for execute command in MetaTrader responseWaiter.WaitOne(WAIT_RESPONSE_TIME); lock (mResponseLocker) { if (mResponseWaiters.ContainsKey(command) == true) { mResponseWaiters.Remove(command); } if (mResponses.ContainsKey(command) == true) { response = mResponses[command]; mResponses.Remove(command); } } } return(response); }
public MtCommandTask(MtCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } Command = command; }
public void EnqueueCommand(MtCommand command) { if (command == null) return; lock (_locker) { mCommands.Enqueue(command); mCurrentExecutor.NotifyCommandReady(); } }
public void SendResponse(MtResponse response) { MtCommand command = mCommand; mCommand = null; ICommandManager commandManager = CommandManager; if (commandManager != null) { commandManager.OnCommandExecuted(this, command, response); } }
public void EnqueueCommand(MtCommand command) { if (command == null) { return; } lock (_locker) { mCommands.Enqueue(command); mCurrentExecutor.NotifyCommandReady(); } }
public MtResponse SendCommand(MtCommand command) { MtResponse response = null; if (command != null) { var task = new MtCommandTask(command); _executorManager.EnqueueCommandTask(task); //wait for execute command in MetaTrader response = task.WaitResult(WAIT_RESPONSE_TIME); } return(response); }
public MtResponse SendCommand(MtCommand command) { Log.DebugFormat("SendCommand: begin. command {0}", command); if (command == null) { Log.Warn("SendCommand: end. command is not defined"); return(null); } var task = new MtCommandTask(command); _executorManager.EnqueueCommandTask(task); //wait for execute command in MetaTrader var response = task.WaitResult(WaitResponseTime); return(response); }
public MtCommandTask SendCommand(MtCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } var task = new MtCommandTask(command); Log.DebugFormat("SendTask: begin. command = {0}", command); ITaskExecutor executor; lock (_locker) { if (_executorMap.ContainsKey(command.ExpertHandle)) { executor = _executorMap[command.ExpertHandle]; } else { executor = _executorList.Count > 0 ? _executorList[0] : null; } } if (executor == null) { Log.Error("SendTask: Executor is null!"); } else { executor.Execute(task); } Log.Debug("SendTask: end."); return(task); }
public void OnCommandExecuted(MtExpert expert, MtCommand command, MtResponse response) { if (expert == null) { return; } if (CommandExecuted != null) { CommandExecuted(this, new MtCommandExecuteEventArgs(command, response)); } lock (_locker) { if (expert == mCurrentExecutor) { if (mCommands.Count > 0) { mCurrentExecutor.NotifyCommandReady(); } } } }
public MtResponse SendCommand(MtCommand command) { MtResponse response = null; if (command != null) { EventWaitHandle responseWaiter = new AutoResetEvent(false); lock (mResponseLocker) { mResponseWaiters[command] = responseWaiter; } mExecutorManager.EnqueueCommand(command); //wait for execute command in MetaTrader responseWaiter.WaitOne(WAIT_RESPONSE_TIME); lock (mResponseLocker) { if (mResponseWaiters.ContainsKey(command) == true) { mResponseWaiters.Remove(command); } if (mResponses.ContainsKey(command) == true) { response = mResponses[command]; mResponses.Remove(command); } } } return response; }
public MtResponse SendCommand(MtCommand command) { return(Channel.SendCommand(command)); }
public void OnCommandExecuted(MtExpert expert, MtCommand command, MtResponse response) { if (expert == null) return; if (CommandExecuted != null) { CommandExecuted(this, new MtCommandExecuteEventArgs(command, response)); } lock (_locker) { if (expert == mCurrentExecutor) { if (mCommands.Count > 0) { mCurrentExecutor.NotifyCommandReady(); } } } }
public MtResponse SendCommand(MtCommand command) { return mServer.SendCommand(command); }
public MtResponse SendCommand(MtCommand command) { return(mServer.SendCommand(command)); }
public MtCommandExecuteEventArgs(MtCommand command, MtResponse response) { Command = command; Response = response; }
public MtResponse SendCommand(MtCommand command) { Log.DebugFormat("SendCommand: called. command = {0}", command); return(_server.SendCommand(command)); }
public MtCommandTask(MtCommand command) { Command = command; }