예제 #1
0
        private void LoadConversationManagerAsync()
        {
            BackgroundWorker backgroundWorker = new BackgroundWorker();

            _progressCallback = new LoadingProgressCallback(backgroundWorker);

            backgroundWorker.WorkerReportsProgress      = true;
            backgroundWorker.WorkerSupportsCancellation = true;
            backgroundWorker.DoWork             += OnDoWork;
            backgroundWorker.ProgressChanged    += OnProgressChanged;
            backgroundWorker.RunWorkerCompleted += OnWorkerCompleted;

            _progressDialog         = new LoadingProgressDialogView();
            _progressDialog.Owner   = this;
            _progressDialog.Cancel += OnCancelProcess;
            AsyncLoadingProgressParams workParams = new AsyncLoadingProgressParams(_progressCallback, _displayOptions.MergeContacts, _deviceInfo);

            backgroundWorker.RunWorkerAsync(workParams);
            _progressDialog.ShowDialog();
        }
예제 #2
0
        private void OnWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                if (_conversationManager == null)
                {
                    Application.Current.Shutdown();
                }
                else if (_progressDialog != null)
                {
                    _progressDialog.Close();
                }
            }
            else if (e.Error != null)
            {
                _progressDialog.Close();

                //
                // If the database file is unreadable, don't auto-open it.
                //

                if (_displayOptions != null)
                {
                    _phoneSelectOptions.PhoneDataPath = "";
                    _phoneSelectOptions.Save();
                }

                if (e.Error is DirectoryNotFoundException)
                {
                    ShowDatabaseErrorDialog(new MissingBackupPathException());
                }
                else if (e.Error is FileNotFoundException)
                {
                    FileNotFoundException ex = (FileNotFoundException)e.Error;
                    ShowDatabaseErrorDialog(new MissingBackupFileException(ex.FileName, ex));
                }
                else if (e.Error is UnreadableDatabaseFileException)
                {
                    UnreadableDatabaseFileException ex = (UnreadableDatabaseFileException)e.Error;
                    ShowDatabaseErrorDialog(ex);
                }
                else
                {
                    FailHandler.HandleUnrecoverableFailure(e.Error);
                }

                Application.Current.Shutdown();
            }
            else
            {
                _conversationManager = (IConversationManager)e.Result;

                UpdateModels();

                PopulateConversationList();

                Update();

                _progressDialog.Close();

                _progressCallback = null;
                _progressDialog = null;

                ShowTextsOutOfDateWarningIfNeeded();
            }
        }
예제 #3
0
        private void LoadConversationManagerAsync()
        {
            BackgroundWorker backgroundWorker = new BackgroundWorker();
            _progressCallback = new LoadingProgressCallback(backgroundWorker);

            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.WorkerSupportsCancellation = true;
            backgroundWorker.DoWork += OnDoWork;
            backgroundWorker.ProgressChanged += OnProgressChanged;
            backgroundWorker.RunWorkerCompleted += OnWorkerCompleted;

            _progressDialog = new LoadingProgressDialogView();
            _progressDialog.Owner = this;
            _progressDialog.Cancel += OnCancelProcess;
            AsyncLoadingProgressParams workParams = new AsyncLoadingProgressParams(_progressCallback, _displayOptions.MergeContacts, _deviceInfo);

            backgroundWorker.RunWorkerAsync(workParams);
            _progressDialog.ShowDialog();
        }