public virtual executionResult startExecutable(string toExecute, string args, string workingDir = null, cancellableDateTime deadline = null) { if (deadline == null) { deadline = new cancellableDateTime(TimeSpan.FromMinutes(3)); } IAsyncExecutionResult resultInProgress = null; try { while (resultInProgress == null) { resultInProgress = startExecutableAsync(toExecute, args, workingDir); // FIXME!!! // This is causing an awful assembly load failure when it throws :/ // Disabling the timeout for now because I am waaay behind schedule already // if (DateTime.Now > deadline) // throw new hypervisorExecutionException(); deadline.doCancellableSleep(TimeSpan.FromSeconds(3)); } while (true) { deadline.doCancellableSleep(TimeSpan.FromSeconds(3)); executionResult res = resultInProgress.getResultIfComplete(); if (res != null) { return(res); } } } finally { if (resultInProgress != null) { resultInProgress.Dispose(); } } }
public static void doExecTestAsync(clientExecutionMethod exec) { using (hypervisor_vmware hyp = machinePools.vmware.createHypervisorForNextFreeVMOrWait(execType: exec)) { prepVM(hyp); IAsyncExecutionResult asyncRes = null; while (asyncRes == null) { asyncRes = hyp.startExecutableAsync("cmd.exe", "/c choice /t 5 /d y >nul & echo This is a test&echo and stderr 1>&2 & exit /b 1234"); } executionResult res = null; while (res == null) { res = asyncRes.getResultIfComplete(); Thread.Sleep(TimeSpan.FromSeconds(1)); } Assert.AreEqual("This is a test\r\n", res.stdout); Assert.AreEqual("and stderr \r\n", res.stderr); Assert.AreEqual(1234, res.resultCode); } }