コード例 #1
0
        protected override void OnLoaded()
        {
            base.OnLoaded();

            AmountMonitor.Default.MonitorCallBack += walletAmountData =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    CanUseMoney = walletAmountData.CanUseAmount;

                    WaitMoney = walletAmountData.WaitAmount;

                    TotalMoney = walletAmountData.TotalAmount;
                });
            };

            TradeRecodesMonitor.Default.MonitorCallBack += tradeRecords =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    if (tradeRecords.Count <= 5)
                    {
                        TradeRecords = tradeRecords;
                    }
                    else
                    {
                        TradeRecords.Clear();
                        tradeRecords.Take(5).ToList().ForEach(x => TradeRecords.Add(x));
                    }
                });
            };
        }
コード例 #2
0
ファイル: TradeRecordViewModel.cs プロジェクト: omcdev/wallet
        void RefreshRecords(bool showLoading = true)
        {
            refreshTimer.Stop();
            var count = TradeRecords.Count;

            if (count < 20)
            {
                count = 20;
            }
            if (showLoading)
            {
                StaticViewModel.GlobalViewModel.IsLoading = true;
            }
            Task task = new Task(() =>
            {
                var filterData         = GetFilterCondition();
                var tradeRecordsResult = OmniCoinService.Default.ListFilterTrans(filterData, 0, true, count);
                if (!tradeRecordsResult.IsFail)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        TradeRecords.Clear();
                        tradeRecordsResult.Value.ToList().ForEach(x => TradeRecords.Add(x));
                    });
                }
            });

            task.ContinueWith(t =>
            {
                if (showLoading)
                {
                    StaticViewModel.GlobalViewModel.IsLoading = false;
                }
                _timerCount = 10;
                refreshTimer.Start();
            });
            task.Start();
        }