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;
        }
Exemple #2
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);
        }
Exemple #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (context != null && context.TempDirectory != null)
                    {
                        if (context.TempDirectory.Exists)
                        {
                            context.TempDirectory.Delete(true);
                        }
                    }

                    if (dialog != null)
                    {
                        dialogAdapter = null;
                        dialog.Dispose();
                    }
                }

                this.disposed = true;
            }
        }
Exemple #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (context != null && context.TempDirectory != null)
                    {
                        if (context.TempDirectory.Exists)
                            context.TempDirectory.Delete(true);
                    }

                    if (dialog != null)
                    {
                        dialogAdapter = null;
                        dialog.Dispose();
                    }
                }

                this.disposed = true;
            }
        }