mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-17 12:48:11 +00:00
Issue #296: MtApi5 - Added property CommandTimeout to define time for waiting result of response from MetaTrader. Default value 30 sec
This commit is contained in:
+14
-1
@@ -32,11 +32,24 @@ namespace MtApi5
|
||||
|
||||
private HashSet<int> _experts = [];
|
||||
private Dictionary<int, Mt5Quote> _quotes = [];
|
||||
private volatile int _command_timeout = 30000; // 30 seconds
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
private IMtLogger Log { get; }
|
||||
|
||||
// Time in milliseconds to wait for a response from MetaTrader for a command. Default is 30 seconds.
|
||||
public int CommandTimeout
|
||||
{
|
||||
get => _command_timeout;
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
throw new ArgumentException("Command timeout must be greater than zero.");
|
||||
_command_timeout = value;
|
||||
}
|
||||
}
|
||||
|
||||
public MtApi5Client(IMtLogger? log = null)
|
||||
{
|
||||
_mtEventHandlers[Mt5EventTypes.OnBookEvent] = ReceivedOnBookEvent;
|
||||
@@ -3588,7 +3601,7 @@ namespace MtApi5
|
||||
var payloadJson = payload == null ? string.Empty : JsonConvert.SerializeObject(payload);
|
||||
Log.Debug($"SendCommand: sending '{payloadJson}' ...");
|
||||
|
||||
var responseJson = client.SendCommand(expertHandle, (int)commandType, payloadJson);
|
||||
var responseJson = client.SendCommand(expertHandle, (int)commandType, payloadJson, CommandTimeout);
|
||||
|
||||
Log.Debug($"SendCommand: received response JSON [{responseJson}]");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user