コード例 #1
0
        public DisbandForm(int myTeammateId)
        {
            _accountService = new AccountService();
            _me             = _accountService.GetTeammate(myTeammateId);
            _curAddress     = _me.BtcAddressCurrent;
            _prevAddress    = _me.BtcAddressPrevious;
            _user           = _accountService.GetUser();

            InitializeComponent();

            _textBoxAuxAddress.Text = _accountService.GetAuxWallet(_me.Team.Network).ToString();
            _textBoxAddressTo.Text  = _me.CurDisbanding.WithdrawAddr;

            UpdateStatuses();
            UpdateWithdrawalControls();
            UpdateCosignerOfControls();

            Task.Factory.StartNew(() =>
            {
                if (!_accountService.Closed) // todo: change it to separate contexts
                {
                    var blockchainService = new BlockchainService(_accountService);
                    blockchainService.TryFetchAuxWalletUtxos(true, _me.Team.Network);
                    if (!_closing)
                    {
                        try
                        {
                            this.Invoke((MethodInvoker) delegate()
                            {
                                UpdateStatuses();
                            });
                        }
                        catch (Exception ex) {
                            Logger.WriteException(ex);
                        }
                    }
                }
            });

            Task.Factory.StartNew(() =>
            {
                if (!_accountService.Closed) // todo: change it to separate contexts
                {
                    var blockchainService = new BlockchainService(_accountService);
                    if (_curAddress != null)
                    {
                        _amountSatoshisCurent = blockchainService.FetchBalance(_curAddress);
                    }
                    if (_prevAddress != null)
                    {
                        _amountSatoshisPrevious = blockchainService.FetchBalance(_prevAddress);
                    }
                    if (!_closing)
                    {
                        try
                        {
                            this.Invoke((MethodInvoker) delegate()
                            {
                                UpdateWithdrawalControls();
                            });
                        }
                        catch (Exception ex) {
                            Logger.WriteException(ex);
                        }
                    }
                }
            });
        }