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:
Viacheslav Demydiuk
2026-04-06 20:22:10 +03:00
parent 249b0f9fbb
commit fa1e6b6c62
4 changed files with 44 additions and 3 deletions
@@ -167,6 +167,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Quotes" Background="LightYellow" />
<ListView Grid.Row="1" Margin="2"
@@ -183,6 +184,11 @@
</ListView.View>
</ListView>
<Button Grid.Row="2" Content="Refresh Quotes" Margin="2" Command="{Binding RefreshQuotesCommand}"/>
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Left" Margin="2">
<TextBlock Text="Command timeout (ms):" VerticalAlignment="Center" Margin="2"/>
<TextBox Text="{Binding CommandTimeout}" Width="100" Margin="2"/>
<Button Content="Apply" Margin="2" Command="{Binding TimeoutApplyCommand}"/>
</StackPanel>
</Grid>
</Border>
</Grid>
+22
View File
@@ -163,6 +163,8 @@ namespace MtApi5TestClient
public DelegateCommand GetSymbolsCommand { get; private set; }
public DelegateCommand RefreshQuotesCommand { get; private set; }
public DelegateCommand TimeoutApplyCommand { get; private set; }
#endregion
#region Properties
@@ -210,6 +212,17 @@ namespace MtApi5TestClient
}
}
private int _command_timeout;
public int CommandTimeout
{
get { return _command_timeout; }
set
{
_command_timeout = value;
OnPropertyChanged("CommandTimeout");
}
}
public ObservableCollection<QuoteViewModel> Quotes { get; } = new ObservableCollection<QuoteViewModel>();
private QuoteViewModel _selectedQuote;
@@ -350,6 +363,7 @@ namespace MtApi5TestClient
ConnectionState = _mtApiClient.ConnectionState;
ConnectionMessage = "Disconnected";
Port = 8228; //default local port
CommandTimeout = _mtApiClient.CommandTimeout;
InitCommands();
@@ -494,6 +508,8 @@ namespace MtApi5TestClient
GetSymbolsCommand = new DelegateCommand(ExecuteGetSymbols);
RefreshQuotesCommand = new DelegateCommand(ExecuteRefreshQuotes);
TimeoutApplyCommand = new DelegateCommand(ExecuteTimeoutApply);
}
private bool CanExecuteConnect(object o)
@@ -1773,6 +1789,12 @@ namespace MtApi5TestClient
}
}
private void ExecuteTimeoutApply(object o)
{
_mtApiClient.CommandTimeout = CommandTimeout;
AddLog($"TimeoutApply: timeout = {CommandTimeout} milliseconds");
}
private static void RunOnUiThread(Action action)
{
Application.Current?.Dispatcher.Invoke(action);