本文整理汇总了C#中System.Progress.?.CompletedInstall方法的典型用法代码示例。如果您正苦于以下问题:C# Progress.?.CompletedInstall方法的具体用法?C# Progress.?.CompletedInstall怎么用?C# Progress.?.CompletedInstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Progress
的用法示例。
在下文中一共展示了Progress.?.CompletedInstall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractAsync
static async Task ExtractAsync(string filename, string destination, Progress progress)
{
Directory.Delete(destination, true);
Directory.CreateDirectory(destination);
var workingDir = Paths.ExecutingDirPath;
var args = $"x \"{filename}\" -o\"{destination}\" -y";
var si = new ProcessStartInfo(@"tools\7z.exe", args)
{
WorkingDirectory = workingDir,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
UseShellExecute = false
};
using (var proc = new Process { StartInfo = si })
{
proc.Start();
var exited = await proc.WaitForExitAsync(ExtractionTimeout);
if (!exited)
{
proc.Kill();
throw new TimeoutException($"Extraction of '{filename}' took longer than {ExtractionTimeout}, aborting");
}
if (proc.ExitCode != 0)
{
// TODO: better exception type
throw new Exception(
$"Failed to extract archive '{filename}'. 7zip exit code: {proc.ExitCode}\n{proc.StandardOutput.ReadToEnd()}\n{proc.StandardError.ReadToEnd()}");
}
progress?.CompletedInstall();
}
}