public async Task T01_Cancel() { var ex = await Assert.ThrowsAnyAsync <OperationCanceledException>(async() => await InterReactClient.BuildAsync(timeout: -1, ct: new CancellationToken(true))); Write(ex.Message); }
public async void Init() { Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(1)).Subscribe(x => Date.Value = DateTime.Now); try { interReactClient = await InterReactClient.BuildAsync(); } catch (Exception exception) { await SyncMessageBox.Show(exception.Message, terminate : true); return; } CoreApplication.Suspending += (x, y) => { interReactClient.Dispose(); }; // TickRedundantRealtimeVolumeFilter removes redundant messages (LastPrice, LastSize, Volume and Time ticks). // Display a message box for any errors. Write messages to the Debug window. interReactClient.Response .Subscribe(async message => { Debug.WriteLine(message.Stringify()); if (message is Alert alert && (alert.AlertType == AlertType.ConnectionLost || alert.AlertType == AlertType.ConnectionRestored)) { await SyncMessageBox.Show(alert.Message); } }, async exception => await SyncMessageBox.Show(exception.Message, terminate: true)); // Note that Symbol is an observable. Symbol.Throttle(TimeSpan.FromSeconds(1)) .DistinctUntilChanged() .Subscribe(async symbol => { try { await FindContract(symbol); } catch (Exception exception) { await SyncMessageBox.Show(exception.Message); } }); }
public async Task T02_Timeout() { var ex = await Assert.ThrowsAsync <TimeoutException>(async() => await InterReactClient.BuildAsync(timeout: 0)); Write(ex.Message); }