public static bool DiffFile(string filename) { if (filename.Length == 0) { return(false); } if (!g_p4installed) { return(NotifyUser("could not find p4.exe installed in perforce directory")); } string token = FormatToken("diff", filename); if (!LockOp(token)) { return(false); } string dirname = Path.GetDirectoryName(filename); // Let's figure out if the user has some custom diff tool installed. Then we just send whatever we have without any fancy options. if (g_p4customdiff) { return(AsyncProcess.Schedule("p4.exe", GetUserInfoString() + " diff \"" + EscapeP4Path(filename) + "#have\"", dirname, new AsyncProcess.OnDone(UnlockOp), token)); } if (g_p4vc_diffhave_supported) { return(AsyncProcess.Schedule(g_p4vc_exename, GetUserInfoString() + " diffhave \"" + filename + "\"", dirname, new AsyncProcess.OnDone(UnlockOp), token, 0)); } // Otherwise let's show a unified diff in the outputpane. return(AsyncProcess.Schedule("p4.exe", GetUserInfoString() + " diff -du \"" + EscapeP4Path(filename) + "#have\"", dirname, new AsyncProcess.OnDone(UnlockOp), token)); }
public MessageRouter(ISerializedMessageHandler serializedMessageHandler, ILogicalEndPoint logicalEndPoint, IRouteManager routeManager, ILogger <MessageRouter> logger = null) { if (serializedMessageHandler == null) { throw new ArgumentNullException(nameof(serializedMessageHandler)); } if (logicalEndPoint == null) { throw new ArgumentNullException(nameof(logicalEndPoint)); } if (routeManager == null) { throw new ArgumentNullException(nameof(routeManager)); } _serializedMessageHandler = serializedMessageHandler; _logicalEndPoint = logicalEndPoint; _routeManager = routeManager; _logger = logger; _receiveProcess = new AsyncProcess(ReceiveProcedure, start: true); _disposeHelper = new AsyncDisposeHelper(DisposeInternalAsync, AsyncDisposeHelperOptions.Synchronize); }
private static bool Internal_EditFileImmediate(OutputWindowPane output, string filename) { if (filename.Length == 0) { return(false); } if (!System.IO.File.Exists(filename)) { return(false); } if (0 == (System.IO.File.GetAttributes(filename) & FileAttributes.ReadOnly)) { return(false); } if (!g_p4installed) { return(NotifyUser("could not find p4 exe installed in perforce directory")); } Log.Debug("EditFileImmediate : " + filename); string token = FormatToken("edit", filename); if (!LockOp(token)) { return(false); } return(AsyncProcess.Run(output, "p4.exe", GetUserInfoString() + "edit \"" + filename + "\"", Path.GetDirectoryName(filename), new AsyncProcess.OnDone(UnlockOp), token)); }
private static async Task <bool> TryCopyAsync(string arguments, string workingDirectory, string errorMessage, CancellationToken cancellationToken) { var xcopyResult = await AsyncProcess.StartAsync( executable : "robocopy", arguments : arguments, lowPriority : false, workingDirectory : workingDirectory, captureOutput : true, isErrorCodeOk : exitCode => exitCode >= 0 && exitCode <= 7, onErrorDataReceived : s => Log.Error($"Copy files error: {s}"), onOutputDataReceived : s => Log.Info($"{s}"), cancellationToken : cancellationToken); foreach (var outputLine in xcopyResult.OutputLines) { Log.Info(outputLine); } // robocopy returns exit codes 0-16 (inclusive) where 0-7 are success, 8-15 are failure, and 16 is fatal error // however, we additionally need to handle negative exit codes for the case of `Process.Kill()` if (xcopyResult.ExitCode < 0 || xcopyResult.ExitCode > 7) { Log.Error(errorMessage); Log.Error(xcopyResult.ErrorLines); return(false); } return(true); }
public static bool RevisionHistoryFile(string dirname, string filename) { if (filename.Length == 0) { return(false); } if (g_p4vc_history_supported || g_p4vinstalled) { string token = FormatToken("history", filename); if (!LockOp(token)) { return(false); } if (g_p4vc_history_supported) { return(AsyncProcess.Schedule(g_p4vc_exename, GetUserInfoString() + " history \"" + filename + "\"", dirname, new AsyncProcess.OnDone(UnlockOp), token, 0)); } if (g_p4vinstalled) { return(AsyncProcess.Schedule("p4v.exe", " -win 0 " + GetUserInfoStringFull(true, dirname) + " -cmd \"history " + EscapeP4Path(filename) + "\"", dirname, new AsyncProcess.OnDone(UnlockOp), token, 0)); } } return(NotifyUser("could not find a supported p4vc.exe or p4v.exe installed in perforce directory")); }
public async Task ExecuteMissingFileAsyncViaRunMethod() { var result = await AsyncProcess.Run($"{Path.GetRandomFileName()}.bloop"); Assert.AreEqual(AsyncProcessCompletionState.ProcessToRunMissing, result.CompletionState); Assert.AreEqual(typeof(Win32Exception), result.Exception.GetType()); }
public bool ExecutePush() { int n = 0; foreach (var i in Push.Select(each => each.ItemSpec)) { Log.LogMessage("Pushing : '{0}'".format(i)); var proc = AsyncProcess.Start(new ProcessStartInfo { FileName = "NuGet.exe", Arguments = "push {0}".format(i), }); proc.StandardOutput.ForEach(each => { if (each.Is()) { Log.LogMessage(each); } }); proc.StandardError.ForEach(each => { if (each.Is()) { Log.LogError(each); } }); if (proc.ExitCode != 0) { return(false); } n++; } Log.LogMessage("Pushed {0} packages".format(n)); return(true); }
#pragma warning restore IDE0032 public ModuleSupervisor(DirectoryInfo directory, IMetadataReader metadataReader, ILogger <ModuleSupervisor> logger = null) { if (directory == null) { throw new ArgumentNullException(nameof(directory)); } if (metadataReader == null) { throw new ArgumentNullException(nameof(metadataReader)); } Directory = directory; _metadataReader = metadataReader; _logger = logger; // Volatile write op (Is avtually not necessary here, because the CLR enforces thread-safety.) _state = ModuleSupervisorState.Initializing; _metadataLazy = new DisposableAsyncLazy <IModuleMetadata>( factory: LookupMetadataAsync, options: DisposableAsyncLazyOptions.Autostart | DisposableAsyncLazyOptions.ExecuteOnCallingThread | DisposableAsyncLazyOptions.RetryOnFailure); _supervisorProcess = new AsyncProcess(SupervisorProcessRoutine, start: true); _disposeHelper = new AsyncDisposeHelper(DisposeInternalAsync); }
/// <summary> /// This creates an RPC server that has endpoints for all the HostAPIs, then creates an elevated process that can call back into this process to report progress. /// /// /// </summary> /// <param name="script"></param> /// <returns></returns> internal int InvokeElevatedViaRPC(string script) { var guid = Guid.NewGuid(); // set up the server IPC channel var serverChannel = new IpcServerChannel(guid.ToString()); ChannelServices.RegisterChannel(serverChannel, true); // RemotingConfiguration.RegisterWellKnownServiceType( typeof(ChocolateyRequest), "Request", WellKnownObjectMode.Singleton); var objRef = RemotingServices.Marshal(_request); // Create the client elevated var process = AsyncProcess.Start(new ProcessStartInfo { FileName = ChocolateyRequest.NuGetExePath, Arguments = string.Format("-rpc {0}", objRef.URI), // WorkingDirectory = workingDirectory, WindowStyle = ProcessWindowStyle.Hidden, Verb = "runas", }); process.WaitForExit(); RemotingServices.Disconnect(_request); return(0); }
public bool ExecuteElevatedAction(string provider, string payload, IRequestObject requestObject) { Activity(); if (requestObject == null) { throw new ArgumentNullException("requestObject"); } // launches a new elevated host that // talks back to this (unelevated) host for everything in HostApi // everything else should be handled in the new process. var guid = Guid.NewGuid(); var properties = new Hashtable(); properties.Add("portName", "OneGet_" + guid); properties.Add("authorizedGroup", "Administrators"); properties.Add("secure", "true"); properties.Add("exclusiveAddressUse", "true"); properties.Add("strictBinding", "false"); properties.Add("name", "OneGetHost"); // set up the server IPC channel var serverChannel = new IpcServerChannel(properties, new BinaryServerFormatterSinkProvider(properties, null)); ChannelServices.RegisterChannel(serverChannel, true); var instance = new RemotableHostApi(requestObject.As <IHostApi>()); var objRef = RemotingServices.Marshal(instance, "Host", typeof(IHostApi)); var remoteUris = serverChannel.GetUrlsForUri("Host"); var uri = remoteUris[0]; // Create the client elevated try { var process = AsyncProcess.Start(new ProcessStartInfo { FileName = Assembly.GetExecutingAssembly().Location, Arguments = "{0} {1} {2}".format(uri, provider, (string.IsNullOrWhiteSpace(payload) ? "null" : payload).ToBase64()), #if !DEBUG WindowStyle = ProcessWindowStyle.Hidden, #endif Verb = "runas", }); process.WaitForExit(); if (process.ExitCode != 0) { return(false); } } catch (Exception e) { e.Dump(); return(false); } finally { RemotingServices.Disconnect(instance); ChannelServices.UnregisterChannel(serverChannel); } return(true); }
public static void IssueADBCmdASync(AsyncProcess procInstance, ADBCommand cmd) { _Closure$__14 e$__ = new _Closure$__14 { $VB$Local_procInstance = procInstance, $VB$Local_cmd = cmd }; new Thread(new ThreadStart(e$__._Lambda$__93)).Start(); }
public async Task NonExistingCommandShouldThrow() { using (var proc = new AsyncProcess(boots) { Command = Guid.NewGuid().ToString() }) { await Assert.ThrowsAsync <Win32Exception> (() => proc.RunAsync(new CancellationToken())); } }
public async Task Run(CancellationToken cancellationToken) { var absoluteFastBuildLocation = Path.GetFullPath(m_startInfo.FastBuildExecutableLocation); if (!File.Exists(absoluteFastBuildLocation)) { throw new FileNotFoundException($"The FastBuild application at '{absoluteFastBuildLocation}' does not exist."); } var absoluteBffLocation = Path.GetFullPath(m_startInfo.FastBuildConfigLocation); if (!File.Exists(absoluteBffLocation)) { throw new FileNotFoundException($"The FastBuild config at '{absoluteBffLocation}' does not exist."); } var absoluteBffDirectory = Path.GetDirectoryName(absoluteBffLocation); if (absoluteBffDirectory == null) { throw new DirectoryNotFoundException($"The FastBuild config directory for '{absoluteBffLocation}' is invalid."); } var bffFileName = Path.GetFileName(absoluteBffLocation); if (!bffFileName.Equals("FBuild.bff", StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException($"The FastBuild config at '{absoluteBffLocation}' is not named 'FBuild.bff'"); } var arguments = GenerateCommandLineArguments(m_startInfo); var startInfo = new AsyncProcessStartInfo(absoluteFastBuildLocation, arguments) { CaptureOutputToProcessResult = ProcessOutputCaptureMode.Both, WorkingDirectory = absoluteBffDirectory }; if (m_outputCallbackAction != null) { startInfo.OnStandardOutputReceived += x => m_outputCallbackAction(OutputType.Information, x); startInfo.OnStandardErrorReceived += x => m_outputCallbackAction(OutputType.Error, x); } using (var process = new AsyncProcess(startInfo, cancellationToken)) { var result = await process.Run(); if (result.ExitCode != 0) { throw new FastBuildRunnerException($"FastBuild resulted in the exit code '{result.ExitCode}'", m_startInfo, result); } } }
public async Task ExecutePingAsyncViaClassAndCheckExitCode() { using (var process = new AsyncProcess(new AsyncProcessStartInfo("ping.exe"))) { var result = await process.Run(); Assert.AreEqual(AsyncProcessCompletionState.Completed, result.CompletionState); Assert.AreEqual(1, result.ExitCode); } }
public Task<int> GdalExtractWithTranslate(string source,string target, string projwin, string outtype, int? outputsize = null, params string[] createOptions) { var process = new AsyncProcess(@"%GDAL%\gdal_translate") { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@" -of {2} {5} {4} -projwin {1} ""{0}"" ""{3}"" ", source, projwin, outtype,target, outputsize.HasValue ? string.Format("-outsize {0} {0}",outputsize.Value):"", string.Join(" ", createOptions.Select(co => string.Format("-co {0}",co))) )); //(outtype=="gtiff") ? "-co COMPRESS=LZW -co PREDICTOR=2" : (outtype=="png"?"-co WORLDFILE=YES":"") }
public async Task EchoShouldNotThrow() { using (var proc = new AsyncProcess(boots) { Command = Helpers.IsWindows ? "cmd" : "echo", Arguments = Helpers.IsWindows ? "/C echo test" : "test" }) { await proc.RunAsync(new CancellationToken()); } }
public bool StartChocolateyProcessAsAdmin(string statements, string exeToRun, bool minimized, bool noSleep, int[] validExitCodes, string workingDirectory) { Debug("Calling 'ChocolateyRequest::XXXX' '{0}','{1}','{2}','{3}','{4}','{5}' ", statements, exeToRun, minimized, noSleep, validExitCodes.Select(each => each.ToString()).SafeAggregate((current, each) => current + "," + each), workingDirectory); if (exeToRun.EqualsIgnoreCase("powershell")) { // run as a powershell script if (IsElevated) { Verbose("Already Elevated - Running PowerShell script in process"); // in proc, we're already good. return(Invoke(statements)); } Verbose("Not Elevated - Running PowerShell script in new process"); // otherwise setup a new proc Error(ErrorCategory.InvalidOperation, statements, "Unable to elevate process (this prototype can't do that right now)"); return(false); } // just a straight exec from here. try { Verbose("Launching Process-EXE :'{0}'", exeToRun); var process = AsyncProcess.Start(new ProcessStartInfo { FileName = exeToRun, Arguments = statements, WorkingDirectory = workingDirectory, WindowStyle = minimized ? ProcessWindowStyle.Hidden : ProcessWindowStyle.Normal, Verb = IsElevated ? "" : "runas", }); while (!process.WaitForExit(1)) { if (IsCanceled) { process.Kill(); Verbose("Process Killed - Host requested cancellation"); throw new Exception("Killed Process {0}".format(exeToRun)); } } if (validExitCodes.Contains(process.ExitCode)) { Verbose("Process Exited Successfully.", "{0}", exeToRun); return(true); } Verbose("Process Failed {0}", exeToRun); throw new Exception("Process Exited with non-successful exit code {0} : {1} ".format(exeToRun, process.ExitCode)); } catch (Exception e) { e.Dump(this); Error("Process Execution Failed", "'{0}' -- {1}", exeToRun, e.Message); throw e; } }
public static async Task RunAsync(string fileName, string arguments, CancellationToken cancellationToken = default) { ProcessStartInfo startInfo = new ProcessStartInfo(fileName, arguments); Task <ProcessResult> task = AsyncProcess.StartAsync(startInfo, cancellationToken); ProcessResult result = await task; PrintOutput(result); PrintError(result); PrintExitCode(result);
private void ExecStandalone(Request request, string uninstallCommand) { // we could examine the EXE a bit here to see if it's a NSIS installer and if it is, tack on a /S to get it to go silently. // uninstall via standalone EXE var proc = AsyncProcess.Start(new ProcessStartInfo { FileName = uninstallCommand, }); proc.WaitForExit(); }
public static bool P4VShowFile(string filename) { if (filename.Length == 0) { return(false); } if (g_p4vinstalled) // note that the cmd line also accepts -t to open P4V with a specific tab shown { return(AsyncProcess.Schedule("p4v.exe", " -win 0 " + GetUserInfoStringFull(true, Path.GetDirectoryName(filename)) + " -s \"" + filename + "\"", Path.GetDirectoryName(filename), null, null, 0)); } return(NotifyUser("could not find p4v.exe installed in perforce directory")); }
public async Task RunWithOutput() { using (var proc = new AsyncProcess(boots) { Command = Helpers.IsWindows ? "cmd" : "echo", Arguments = Helpers.IsWindows ? "/C echo test" : "test" }) { var text = await proc.RunWithOutputAsync(new CancellationToken()); Assert.Equal("test", text.Trim()); } }
private void CancelJob(AsyncProcess process, object hint) { string str = hint as string; AsyncExecuteCommandProcess executeCommandProcess = process as AsyncExecuteCommandProcess; if (executeCommandProcess == null || executeCommandProcess.Cancel || !(executeCommandProcess.Name == str) && str != null) { return; } executeCommandProcess.Cancel = true; executeCommandProcess.Kill(); }
static async Task Runner(AsyncProcess host, CancellationToken cancel) { while (true) { var replay = await host.ReadLineAsync(cancel); if (replay == null) { return; } Console.WriteLine("< " + replay); } }
public async Task <GuessitResult> GuessName(string filename) { try { var output = await AsyncProcess.StartWithOuput("guessit", $"-j \"{filename}\"", ProcessRedirectStream.StandardOuput); return(JsonConvert.DeserializeObject <GuessitResult>(output)); } catch (Exception e) { Debug.Print("GuessIt error: " + e.Message); return(null); } }
public async Task CancelRunningProcess() { var cancellationSource = new CancellationTokenSource(); var token = cancellationSource.Token; using (var process = new AsyncProcess(new AsyncProcessStartInfo("notepad.exe"), token)) { var runTask = process.Run(); await Task.Delay(500, token); cancellationSource.Cancel(); var result = await runTask; Assert.AreEqual(AsyncProcessCompletionState.Cancelled, result.CompletionState); Assert.AreEqual(int.MinValue, result.ExitCode); } }
public static bool P4WinShowFile(OutputWindowPane output, string filename) { if (filename.Length == 0) { return(false); } if (g_p4wininstalled && !Singleton <Config> .Instance.preferVisualClient) { return(AsyncProcess.Schedule(output, "p4win.exe", GetUserInfoStringFull(true, Path.GetDirectoryName(filename)) + " -q -s \"" + filename + "\"", Path.GetDirectoryName(filename), null, null, 0)); } if (g_p4vinstalled) { return(AsyncProcess.Schedule(output, "p4v.exe", " -win 0 " + GetUserInfoStringFull(true, Path.GetDirectoryName(filename)) + " -cmd \"open " + filename + "\"", Path.GetDirectoryName(filename), null, null, 0)); } return(NotifyUser("could not find p4win.exe or p4v.exe installed in perforce directory")); }
public static bool DiffFile(OutputWindowPane output, string filename) { if (filename.Length == 0) { return(false); } string token = FormatToken("diff", filename); if (!LockOp(token)) { return(false); } if (g_p4wininstalled /*&& !Singleton<Config>.Instance.preferVisualClient*/) { return(AsyncProcess.Schedule(output, "p4win.exe", GetUserInfoString() + " -D \"" + filename + "#have\"", Path.GetDirectoryName(filename), new AsyncProcess.OnDone(UnlockOp), token, 0)); } // NOTE: this doesn't work since it leaves zombie p4v processes around! /* * if (g_p4vinstalled) * { * string arguments = " -win 0 "; * arguments += GetUserInfoStringFull(true, Path.GetDirectoryName(filename)); * arguments += " -cmd \"prevdiff \"" + filename + "\""; * return AsyncProcess.Schedule(output, "p4v.exe", arguments, Path.GetDirectoryName(filename), new AsyncProcess.OnDone(UnlockOp), token); * }*/ if (g_p4installed) { // Let's figure out if the user has some custom diff tool installed. Then we just send whatever we have without any fancy options. if (g_p4customdiff) { return(AsyncProcess.Schedule(output, "p4.exe", GetUserInfoString() + " diff \"" + filename + "#have\"", Path.GetDirectoryName(filename), new AsyncProcess.OnDone(UnlockOp), token)); } else { // Otherwise let's show a unified diff in the outputpane. return(AsyncProcess.Schedule(output, "p4.exe", GetUserInfoString() + " diff -du \"" + filename + "#have\"", Path.GetDirectoryName(filename), new AsyncProcess.OnDone(UnlockOp), token)); } } return(NotifyUser("could not find p4win.exe/p4.exe installed in perforce directory")); }
public async Task PingGoogleAndCaptureOutputInResult() { using (var process = new AsyncProcess(new AsyncProcessStartInfo("ping.exe", "www.google.com") { CaptureOutputToProcessResult = ProcessOutputCaptureMode.Output })) { var result = await process.Run(); Assert.AreEqual(AsyncProcessCompletionState.Completed, result.CompletionState); Assert.AreEqual(0, result.ExitCode); Assert.IsNotNull(result.StandardOutput); Assert.IsNull(result.StandardError); Assert.IsTrue(result.StandardOutput.Length > 0); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void Dispose(bool disposing) { if (disposing) { if (m_process != null) { m_process.Dispose(); m_process = null; } if (m_exitMutex != null) { m_exitMutex.Dispose(); m_exitMutex = null; } } }
public static bool RevisionGraph(string dirname, string filename) { if (string.IsNullOrEmpty(g_p4vc_exename)) { return(NotifyUser("could not find p4vc in perforce directory")); } string arguments = GetUserInfoString(); arguments += " revisiongraph \"" + filename + "\""; string token = FormatToken("revisiongraph", filename); if (!LockOp(token)) { return(false); } return(AsyncProcess.Schedule(g_p4vc_exename, arguments, dirname, new AsyncProcess.OnDone(UnlockOp), token, 0)); }
public static bool DeleteFile(OutputWindowPane output, string filename) { if (filename.Length == 0) { return(false); } if (!g_p4installed) { return(NotifyUser("could not find p4 exe installed in perforce directory")); } string token = FormatToken("delete", filename); if (!LockOp(token)) { return(false); } return(AsyncProcess.Schedule(output, "p4.exe", GetUserInfoString() + "delete \"" + filename + "\"", Path.GetDirectoryName(filename), new AsyncProcess.OnDone(UnlockOp), token)); }
public Task<double[]> GetGdalExtentAsync(string source) { var process = new AsyncProcess<double[]>(@"%GDAL%\gdalinfo", parseRasterExtent) { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@"""{0}""", source)); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void Dispose (bool disposing) { if (disposing) { if (m_process != null) { m_process.Dispose (); m_process = null; } if (m_exitMutex != null) { m_exitMutex.Dispose (); m_exitMutex = null; } } }
public Task<string> GetProj4TextAsync(string source, string layer = null) { var path = Path.ChangeExtension(source, "prj"); var process = new AsyncProcess<string>(@"%GDAL%\gdalsrsinfo", parseProj4) { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@"""{0}""", path)); }
public Task<int> AddSpatialIndexToMSQL(string connectionstring,string tablename) { var process = new AsyncProcess(@"%GDAL%\ogrinfo") { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@" ""{1}"" -sql ""create spatial index on {0}""", tablename, connectionstring)); }
public Task<int> Ogr2OgrClipAsync(string source,string target, string t_srs, double[] extent) { var process = new AsyncProcess(@"%GDAL%\ogr2ogr") { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@"{0} {1} -t_srs {2} -spat {3}", target, source, t_srs, string.Join(" ", extent))); }
public Task<int> BuildVrtFileAsync(string filelist, string outputfile) { var process = new AsyncProcess(@"%GDAL%\gdalbuildvrt") { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@" -input_file_list ""{0}"" ""{1}""", filelist, outputfile)); }
public Task<double[]> GetOgrExtentAsync(string source, string layer=null) { var process = new AsyncProcess<double[]>(@"%GDAL%\ogrInfo", parseExtent) { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder}; return process.RunAsync(string.Format(@"-so -al ""{0}"" {1}", source, layer)); }
public Task<GdalInfoResult> GetGDALInfoAsync(string source) { var process = new AsyncProcess<GdalInfoResult>(@"%GDAL%\gdalinfo", parseGDALInfo) { EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder }; return process.RunAsync(string.Format(@"""{0}""", source)); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void Start (EventListener listener) { m_startTicks = Environment.TickCount; m_lastOutputTimestamp = m_startTicks; m_exitMutex = new ManualResetEvent (false); m_listener = listener; m_process = new AsyncProcess (); m_process.StartInfo = StartInfo; m_process.OutputDataReceived += new DataReceivedEventHandler (ProcessStdout); m_process.ErrorDataReceived += new DataReceivedEventHandler (ProcessStderr); m_process.Exited += new EventHandler (ProcessExited); m_process.EnableRaisingEvents = true; LoggingUtils.Print (string.Format ("[AsyncRedirectProcess] Start: {0} (Args=\"{1}\" Pwd=\"{2}\")", m_process.StartInfo.FileName, m_process.StartInfo.Arguments, m_process.StartInfo.WorkingDirectory)); if (!m_process.Start ()) { m_exitMutex.Set (); throw new InvalidOperationException ("Could not spawn async process - " + m_process.StartInfo.FileName); } m_process.BeginOutputReadLine (); m_process.BeginErrorReadLine (); m_stdInputWriter = TextWriter.Synchronized (m_process.StandardInput); }
private void timer1_Tick(object sender, EventArgs e) { AsyncProcess caller = new AsyncProcess(CaptureScreen); caller.BeginInvoke(_counter, this._screenSize, this._finalSize, chkHaloMouse.Checked, chkIncludeMouse.Checked, _saveLocation, _radius, null, null); _counter++; }