Exemplo n.º 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);
        }
Exemplo n.º 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;
        }