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(int commandType, ArrayList commandParameters) { Debug.WriteLine("[INFO] MtClient::SendCommand: commandType = {0}", commandType); MtResponse result = null; try { lock (mClientLocker) { if (mProxy != null && mIsConnected == true) { result = mProxy.SendCommand(new MtCommand(commandType, commandParameters)); } } } catch (Exception ex) { Debug.WriteLine("[ERROR] MtClient::SendCommand: {0}", ex.Message); Close(); throw new CommunicationException("Service connection failed! " + ex.Message); } return(result); }
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 void SetResult(MtResponse result) { lock (_locker) { _result = result; } _responseWaiter.Set(); }
public void SendResponse(MtResponse response) { Log.DebugFormat("SendResponse: begin. response = {0}", response); _currentTask.SetResult(response); _currentTask = null; Log.Debug("SendResponse: end."); }
public void SendResponse(MtResponse response) { Log.DebugFormat("SendResponse: begin. response = {0}", response); _commandTask.SetResult(response); _commandTask = null; FireOnCommandExecuted(); Log.Debug("SendResponse: end."); }
public void SendResponse(MtResponse response) { MtCommand command = mCommand; mCommand = null; ICommandManager commandManager = CommandManager; if (commandManager != null) { commandManager.OnCommandExecuted(this, command, response); } }
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 void SendResponse(int expertHandle, MtResponse response) { Debug.WriteLine("MtApiServerInstance::SendResponse: id = {0}, response = {1}", expertHandle, response); MtExpert expert = null; lock (mExpertsDictionary) { expert = mExpertsDictionary[expertHandle]; } if (expert != null) { expert.SendResponse(response); } Debug.WriteLine("MtApiServerInstance::SendResponse: finish"); }
public void SendResponse(int expertHandle, MtResponse response) { Log.DebugFormat("SendResponse: begin. id = {0}, response = {1}", expertHandle, response); MtExpert expert; lock (_experts) { expert = _experts[expertHandle]; } if (expert != null) { expert.SendResponse(response); } else { Log.WarnFormat("SendResponse: expert with id {0} has not been found.", expertHandle); } Log.Debug("SendResponse: end"); }
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 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 void SendResponse(MtResponse response) { _commandTask.SetResult(response); _commandTask = null; FireOnCommandExecuted(); }
public MtCommandExecuteEventArgs(MtCommand command, MtResponse response) { Command = command; Response = response; }