예제 #1
0
        private void CheckUpdate()
        {
            Task.Factory.StartNew(() =>
            {
                var update = new Update();
                UpdateWindow updateWindow = null;

                while (true)
                {
                    try
                    {
                        if ((updateWindow == null || !updateWindow.IsVisible) && update.IsUpdateAvailable)
                        {
                            if (update.IsUpdateAvailable)
                            {
                                update.DownloadUpdate();

                                try
                                {
                                    update.DownloadReleaseNotes();
                                }
                                catch (Exception exc)
                                {
                                    logger.Warn(exc, "Failed to download release notes.");
                                }

                                Dispatcher.Invoke(() =>
                                {
                                    updateWindow = new UpdateWindow()
                                    {
                                        Owner = this
                                    };

                                    updateWindow.SetUpdate(update);
                                    updateWindow.Show();
                                    updateWindow.Focus();
                                });
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        logger.Error(exc, "Failed to process update.");
                    }

                    Thread.Sleep(4 * 60 * 60 * 1000);
                }
            });
        }