예제 #1
0
        internal void HandleActionWithMetrics(UIElement element, Action action, string eventName = null)
        {
            if (element != null)
            {
                element.IsEnabled = false;
            }

            Task.Run(() =>
            {
                long elapsedTime = 0;

                HandleException(
                    () => elapsedTime = StopWatch.Get(() => action()),
                    () => ChangeControl(() =>
                {
                    if (eventName != null)
                    {
                        tbWatchingEvent.Text = String.Format("{0} ({1} ms)", eventName, elapsedTime);
                    }
                    if (element != null)
                    {
                        element.IsEnabled = true;
                    }
                }));
            });
        }
예제 #2
0
        private void OnAuthPassed(object s, EventArgs e)
        {
            if (s == null)
            {
                Error("Authorization failed");
                return;
            }
            HandleException(() =>
            {
                var elapsedMs = StopWatch.Get(() => BtxAccount = _controller.GetAccountName());
                _controller.SetBitmexSettings(BtxAccount.Id);

                ChangeControl(() =>
                {
                    HandleException(() =>
                    {
                        foreach (var ctrl in _posControls)
                        {
                            ctrl.Value.InitPositionWatcher(BtxAccount, _controller.Instruments);
                        }
                        lblBtxAccount.Content    = BtxAccount.UserName;
                        tbWatchingEvent.Text     = String.Format("ACCOUNT ({0} ms)", elapsedMs);
                        datePicker1.SelectedDate = DateTime.Now.Date;

                        LoadDailyTrades();
                        _controller.SubscribeTopics();
                    });
                });
            });
        }
예제 #3
0
        internal void CancelOrder(string orderId)
        {
            long elapsedTime = 0;

            Task.Run(() => HandleException(
                         () => elapsedTime = StopWatch.Get(() => _controller.CancelOrders(orderId)),
                         () => ChangeControl(() => tbWatchingEvent.Text = String.Format("DEL ORD ({0} ms)", elapsedTime))
                         ));
        }