private async Task RunProcessAsync() { string serverDirectory = Path.GetDirectoryName(_server.SRCDSPath); Directory.CreateDirectory(serverDirectory); _steamCMDProcess?.Dispose(); _steamCMDProcess = new Process() { StartInfo = new ProcessStartInfo() { FileName = _server.SteamCMDPath, Arguments = @"+login anonymous +force_install_dir ..\Server +app_update 232250 +quit", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true }, EnableRaisingEvents = true }; _steamCMDProcess.Exited += OnProcessExited; _steamCMDProcess.Start(); string line; while ((line = await _steamCMDProcess.StandardOutput.ReadLineAsync()) != null) { if (IsDisposed) { break; } WriteMessage(line); _steamCMDParser.ParseLine(line); lblStatus.Text = "Status : " + _steamCMDParser.UpdateState; if (_steamCMDParser.Processed <= _steamCMDParser.Total) { lblProgress.Text = ProgressHelper.FormatProgressLine(_steamCMDParser.Processed, _steamCMDParser.Total); prgProgress.Value = ProgressHelper.GetProgressPercentage(_steamCMDParser.Processed, _steamCMDParser.Total); } } }
private void OnProgressChanged(object sender, EventArgs e) { lblProgress.Text = ProgressHelper.FormatProgressLine(_downloader.BytesDownloaded, _downloader.ContentLength); prgProgress.Value = ProgressHelper.GetProgressPercentage(_downloader.BytesDownloaded, _downloader.ContentLength); }