本文整理匯總了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();
}
}