コード例 #1
0
        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);
                }
            });
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: mpvyard/InterReact
 private void Form1_FormClosing(object sender, FormClosingEventArgs e) => client?.Dispose();
コード例 #3
0
 public void Dispose() => client?.Dispose();