Ejemplo n.º 1
0
        private async Task OnWalletProcessOpenedWallet()
        {
            try
            {
                var sdiff = await WalletRpcClient.TicketPriceAsync();

                await App.Current.Dispatcher.InvokeAsync(() => TicketPrice = sdiff);

                var syncingWallet = await WalletRpcClient.Synchronize(OnWalletChangesProcessed);

                WalletMutex = syncingWallet.Item1;
                using (var guard = await WalletMutex.LockAsync())
                {
                    OnSyncedWallet(guard.Instance);
                }

                var   syncTask = syncingWallet.Item2;
                await syncTask;
            }
            catch (ConnectTimeoutException)
            {
                MessageBox.Show("Unable to connect to wallet");
            }
            catch (Grpc.Core.RpcException) when(WalletRpcClient.CancellationRequested)
            {
            }
            catch (Exception ex)
            {
                var ae = ex as AggregateException;
                if (ae != null)
                {
                    Exception inner;
                    if (ae.TryUnwrap(out inner))
                    {
                        ex = inner;
                    }
                }

                await HandleSyncFault(ex);
            }
            finally
            {
                if (WalletMutex != null)
                {
                    using (var walletGuard = await WalletMutex.LockAsync())
                    {
                        walletGuard.Instance.ChangesProcessed -= OnWalletChangesProcessed;
                    }
                }

                var shell = (ShellViewModel)ViewModelLocator.ShellViewModel;
                shell.StartupWizardVisible = true;
            }
        }
Ejemplo n.º 2
0
        private async Task OnWalletProcessOpenedWallet()
        {
            try
            {
                var syncingWallet = await WalletRpcClient.Synchronize(OnWalletChangesProcessed);

                Wallet = syncingWallet.Item1;
                OnSyncedWallet();

                var   syncTask = syncingWallet.Item2;
                await syncTask;
            }
            catch (ConnectTimeoutException)
            {
                MessageBox.Show("Unable to connect to wallet");
            }
            catch (Exception ex)
            {
                var ae = ex as AggregateException;
                if (ae != null)
                {
                    Exception inner;
                    if (ae.TryUnwrap(out inner))
                    {
                        ex = inner;
                    }
                }

                HandleSyncFault(ex);
            }
            finally
            {
                var wallet = Wallet;
                if (wallet != null)
                {
                    wallet.ChangesProcessed -= OnWalletChangesProcessed;
                }
                var shell = (ShellViewModel)ViewModelLocator.ShellViewModel;
                shell.StartupWizardVisible = true;
            }
        }