Exemple #1
0
        public StatusDialog UpdateApplication(EventWaitHandle asyncHandle)
        {
            var feedManager = new FeedManager(this.publicKey);
            var newVersions = feedManager.GetNewVersions(feedUrl, this.context.ApplicationVersion);

            if (dialog == null)
            {
                this.dialog          = new StatusDialog();
                this.dialog.AppTitle = this.context.ApplicationTitle;

                this.dialogAdapter = new StatusDialogAdapter(dialog);
            }

            worker = new UpdateWorker(
                () =>
            {
                var downloadManager = new DownloadManager(this.context, dialogAdapter);
                var files           = downloadManager.DownloadFiles(newVersions);

                var installer = new InstallationManager(this.context, new TraceLogger());
                foreach (var file in files.OrderBy(f => f.Key))
                {
                    installer.Install(file.Value, file.Key);
                }
            });

            worker.WorkCompleted += (object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
                                    =>
            {
                if (dialog != null)
                {
                    dialog.Close();
                    dialog.Dispose();

                    dialogAdapter = null;
                    dialog        = null;
                }

                if (asyncHandle != null)
                {
                    asyncHandle.Set();
                }
            };

            worker.Start();

            return(this.dialog);
        }
            // on correct thread
            private void Run()
            {
                //

                try {
                    lock (this) {
                        if (alreadyStopped)
                        {
                            return;
                        }

                        dialog = new StatusDialog(this, parent.dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        dialog.Visible = true;
                    }

                    if (!alreadyStopped)
                    {
                        Application.Run(dialog);
                    }
                }
                finally {
                    lock (this) {
                        if (dialog != null)
                        {
                            dialog.Dispose();
                            dialog = null;
                        }
                    }
                }
            }
            private void Run()
            {
                // SECREVIEW : need all permissions to make the window not get adorned...
                //
                try {
                    lock (this) {
                        if (alreadyStopped)
                        {
                            return;
                        }

                        dialog = new StatusDialog(this, parent.dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        dialog.Visible = true;
                    }

                    if (!alreadyStopped)
                    {
                        Application.Run(dialog);
                    }
                }
                finally {
                    lock (this) {
                        if (dialog != null)
                        {
                            dialog.Dispose();
                            dialog = null;
                        }
                    }
                }
            }
            private void Run()
            {
                //

                try
                {
                    lock (this)
                    {
                        if (_alreadyStopped)
                        {
                            return;
                        }

                        _dialog = new StatusDialog(this, _parent._dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        _dialog.Visible = true;
                    }

                    if (!_alreadyStopped)
                    {
                        Application.Run(_dialog);
                    }
                }
                finally
                {
                    lock (this)
                    {
                        if (_dialog is not null)
                        {
                            _dialog.Dispose();
                            _dialog = null;
                        }
                    }
                }
            }
            private void Run() {
                // SECREVIEW : need all permissions to make the window not get adorned...
                //
                try {
                    lock (this) {
                        if (alreadyStopped) {
                            return;
                        }

                        dialog = new StatusDialog(this, parent.dialogTitle);
                        ThreadUnsafeUpdateLabel();
                        dialog.Visible = true;
                    }

                    if (!alreadyStopped) {
                        Application.Run(dialog);
                    }
                }
                finally {
                    lock (this) {
                        if (dialog != null) {
                            dialog.Dispose();
                            dialog = null;
                        }
                    }
                }
            }