RestartCurrentApplication() private method

private RestartCurrentApplication ( ) : void
return void
Example #1
0
        private static async Task DownloadAndInstall(CancellationToken token)
        {
            var directory = _directory ?? MainExecutingFile.Directory;

            try {
                var data = await CmApiProvider.GetStaticDataAsync("visual_cpp", TimeSpan.FromDays(1), cancellation : token);

                if (data == null)
                {
                    ManualInstallation(null, directory);
                }
                else
                {
                    await Task.Run(() => {
                        using (var archive = ZipFile.OpenRead(data.Item1)) {
                            foreach (var file in archive.Entries)
                            {
                                var completeFileName = Path.Combine(directory, file.FullName);
                                if (file.Name == "" || File.Exists(completeFileName))
                                {
                                    continue;
                                }
                                FileUtils.EnsureFileDirectoryExists(completeFileName);
                                file.ExtractToFile(completeFileName, true);
                            }
                        }
                    });

                    FileUtils.TryToDelete(data.Item1);
                    if (ModernDialog.ShowMessage("The package is installed. Now, app needs to be restarted. Restart it now?", "The package is installed",
                                                 MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        WindowsHelper.RestartCurrentApplication();
                    }
                }
            } catch (Exception e) when(e.IsCancelled())
            {
            } catch (Exception e) {
                ManualInstallation(e, directory);
            }
        }