本文整理汇总了C#中Process.WaitForExit方法的典型用法代码示例。如果您正苦于以下问题:C# Process.WaitForExit方法的具体用法?C# Process.WaitForExit怎么用?C# Process.WaitForExit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process.WaitForExit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(String[] args)
{
String code = null;
if (args.Length == 0) {
Console.Write("Lift: ");
code = Console.ReadLine();
} else {
if (args.Length == 1 && File.Exists(args[0])) {
code = File.ReadAllText(args[0]);
} else {
code = String.Join(" ", args);
}
}
var temp = Path.GetTempFileName();
File.WriteAllText(temp, "object __wrapper { def wrapper() = scala.reflect.mirror.reify{" + code + "} }");
var process = new Process();
var scala = @"%SCRIPTS_HOME%\scalac.exe".Expand();
process.StartInfo.FileName = scala;
process.StartInfo.Arguments = "-Yreify-copypaste " + temp;
process.StartInfo.UseShellExecute = false;
process.Start();
process.WaitForExit();
}
示例2: OnPostprocessBuild
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
#if UNITY_IOS
string f = "OpenKitIOSBuildLogFile.txt";
string logfile = System.IO.Directory.GetCurrentDirectory() + "/" + f;
UnityEngine.Debug.Log("Logging OpenKit post build to " + f);
LogTo(logfile, "In Editor/OpenKitPostProcessBuildPlayer.cs\n");
Process proc = new Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName = Application.dataPath + "/Plugins/OpenKit/PostbuildScripts/PostBuildOpenKitIOSScript";
proc.StartInfo.Arguments = "'" + pathToBuiltProject + "' '" + FacebookAppID + "'";
// Add the Unity version as an argument to the postbuild script, use 'Unity3' for all 3.x versions and for
// 4 and up use the API to get it
string unityVersion;
#if UNITY_3_5 || UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0
unityVersion = "Unity3";
#else
unityVersion = Application.unityVersion;
#endif
proc.StartInfo.Arguments += " '" + unityVersion + "'";
proc.Start();
proc.WaitForExit();
#endif
}
示例3: GetCustomerMac
//这里是关键函数了
public string GetCustomerMac(string IP)
{
string dirResults = "";
ProcessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
psi.FileName = "nbtstat";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "-a " + IP;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
//匹配mac地址
Match m = Regex.Match(dirResults, "\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w\\w");
//若匹配成功则返回mac,否则返回找不到主机信息
if (m.ToString() != "")
{
return m.ToString();
}
else
{
return "找不到主机信息";
}
}
示例4: GetDebugPort
static int GetDebugPort()
{
if (!Application.isPlaying)
{
return -1;
}
string args = "-c /^Unity$/ -i 4tcp -a";
//* Create your Process
Process process = new Process();
process.StartInfo.FileName = "lsof";
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
// since Unity is not thread safe, we need to call lsof in the mainthread and wait for its output
string output = process.StandardOutput.ReadToEnd();
ParseOutput(output);
process.WaitForExit();
return 1;
}
示例5: GetPrefKeysMac
private void GetPrefKeysMac()
{
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string pListPath = homePath +"/Library/Preferences/unity." + PlayerSettings.companyName + "." +
PlayerSettings.productName + ".plist";
// Convert from binary plist to xml.
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo("plutil", "-convert xml1 \"" + pListPath + "\"");
p.StartInfo = psi;
p.Start();
p.WaitForExit();
StreamReader sr = new StreamReader(pListPath);
string pListData = sr.ReadToEnd();
XmlDocument xml = new XmlDocument();
xml.LoadXml(pListData);
XmlElement plist = xml["plist"];
if (plist == null) return;
XmlNode node = plist["dict"].FirstChild;
while (node != null) {
string name = node.InnerText;
node = node.NextSibling;
PlayerPrefStore pref = new PlayerPrefStore(name, node.Name, node.InnerText);
node = node.NextSibling;
playerPrefs.Add(pref);
}
// // Convert plist back to binary
Process.Start("plutil", " -convert binary1 \"" + pListPath + "\"");
}
示例6: ApplyShader
static bool ApplyShader(string test_name, string shader, string input, string result, string extra)
{
Process applyShader = new Process ();
applyShader.StartInfo.FileName = "mono";
applyShader.StartInfo.UseShellExecute = false;
applyShader.StartInfo.Arguments = string.Format ("../src/shader.exe {0} {1} {2} {3}", extra, shader, input, result);
applyShader.StartInfo.RedirectStandardError = true;
applyShader.StartInfo.RedirectStandardOutput = true;
var stdout = new StringBuilder ();
var stderr = new StringBuilder ();
applyShader.OutputDataReceived += (s, e) => { if (e.Data.Trim ().Length > 0) stdout.Append("\t").Append (e.Data).Append ("\n"); };
applyShader.ErrorDataReceived += (s, e) => { if (e.Data.Trim ().Length > 0) stderr.Append("\t").Append (e.Data).Append ("\n"); };
applyShader.Start ();
applyShader.BeginOutputReadLine ();
applyShader.BeginErrorReadLine ();
applyShader.WaitForExit ();
var exitCode = applyShader.ExitCode;
applyShader.Dispose ();
if (exitCode != 0)
errorList.Add (String.Format ("Test {0} failed with:\n{1}{2}", test_name, stdout, stderr));
return exitCode == 0;
}
示例7: CreateSymbolicLink
/// <summary>Creates a symbolic link using command line tools</summary>
/// <param name="linkPath">The existing file</param>
/// <param name="targetPath"></param>
public static bool CreateSymbolicLink(string linkPath, string targetPath, bool isDirectory)
{
Process symLinkProcess = new Process();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
symLinkProcess.StartInfo.FileName = "cmd";
symLinkProcess.StartInfo.Arguments = string.Format("/c mklink{0} \"{1}\" \"{2}\"", isDirectory ? " /D" : "", linkPath, targetPath);
}
else
{
symLinkProcess.StartInfo.FileName = "ln";
symLinkProcess.StartInfo.Arguments = string.Format("-s \"{0}\" \"{1}\"", targetPath, linkPath);
}
symLinkProcess.StartInfo.RedirectStandardOutput = true;
symLinkProcess.Start();
if (symLinkProcess != null)
{
symLinkProcess.WaitForExit();
return (0 == symLinkProcess.ExitCode);
}
else
{
return false;
}
}
示例8: btnScan_Click
protected void btnScan_Click(object sender, EventArgs e)
{
try
{
string switches = " /inventory /startaddress:" + txt_range_from.Text + " /endaddress:" + txt_range_to.Text + " /computers:no /devices:yes /community:" + txt_community.Text;
ProcessStartInfo info = new ProcessStartInfo(Server.MapPath("~/binaries/Admin.exe"), switches);
Process pro = new Process();
pro.StartInfo = info;
pro.Start();
pro.WaitForExit();
// lbl_status.Text = "Scanning completed...";
txt_community.Text = "";
txt_range_from.Text = "";
txt_range_to.Text = "";
string myScript;
myScript = "<script language=javascript>alert('Scanning completed successfully...');</script>";
Page.RegisterClientScriptBlock("MyScript", myScript);
// return;
}
catch (Exception ex)
{
string myScript;
myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
Page.RegisterClientScriptBlock("MyScript", myScript);
return;
}
}
开发者ID:progressiveinfotech,项目名称:PRO_FY13_40_Helpdesk-Support-and-Customization_EIH,代码行数:28,代码来源:Network_Discovery.aspx.cs
示例9: CheckGDAL
public bool CheckGDAL()
{
try
{
string appPath = "gdalinfo";
StreamReader str0 = StreamReader.Null;
string output = "";
Process prc = new Process();
prc.StartInfo.FileName = appPath;
prc.StartInfo.Arguments = "--version";
prc.StartInfo.UseShellExecute = false;
prc.StartInfo.CreateNoWindow = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.Start();
str0 = prc.StandardOutput;
output = str0.ReadToEnd();
prc.WaitForExit();
str0.Close();
string[] SubStrings = output.Split(' ');
return (SubStrings[0] == "GDAL") ? true : false;
}
catch
{
return false;
}
}
示例10: Main
public static int Main(string[] args)
{
// Only run this test on Unix
int pl = (int) Environment.OSVersion.Platform;
if ((pl != 4) && (pl != 6) && (pl != 128)) {
return 0;
}
// Try to invoke the helper assembly
// Return 0 only if it is successful
try
{
var name = "bug-17537-helper.exe";
Console.WriteLine ("Launching subprocess: {0}", name);
var p = new Process();
p.StartInfo.FileName = Path.Combine (AppDomain.CurrentDomain.BaseDirectory + name);
p.StartInfo.UseShellExecute = false;
var result = p.Start();
p.WaitForExit(1000);
if (result) {
Console.WriteLine ("Subprocess started successfully");
return 0;
} else {
Console.WriteLine ("Subprocess failure");
return 1;
}
}
catch (Exception e)
{
Console.WriteLine ("Subprocess exception");
Console.WriteLine (e.Message);
return 1;
}
}
示例11: Execute
public static int Execute(string CommandLineArgs )
{
int exitCode = 0 ;
try
{
Process process=new Process();
process.StartInfo.FileName="xmlsign.exe" ;
process.StartInfo.UseShellExecute=false;
process.StartInfo.RedirectStandardOutput=true;
process.StartInfo.RedirectStandardInput=true;
process.StartInfo.RedirectStandardError=true;
process.StartInfo.CreateNoWindow=true;
if( CommandLineArgs != null )
process.StartInfo.Arguments = CommandLineArgs ;
process.Start();
Console.WriteLine( process.StandardOutput.ReadToEnd() ) ;
process.WaitForExit();
exitCode = process.ExitCode ;
process.Close();
}
catch(Exception e)
{
Console.WriteLine( e ) ;
exitCode = -1;
}
return exitCode ;
}
示例12: checkConnection
// The state object is necessary for a TimerCallback.
public void checkConnection(object stateObject)
{
Process p = new Process();
Ping pingSender = new Ping ();
p.StartInfo.FileName = "arp";
p.StartInfo.Arguments = "-a";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
string data = "a";
byte[] buffer = Encoding.ASCII.GetBytes (data);
for(int i = 0; i < 25 ; i++){
pingSender.Send ("10.0.0."+i.ToString(),10,buffer);
}
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
string MAC = "xx-xx-xx-xx-xx-xx";
if(output.Contains(MAC)){
SerialPort port = new SerialPort("COM5", 9600);
port.Open();
port.Write("u");
port.Close();
}
else{
SerialPort port = new SerialPort("COM5", 9600);
port.Open();
port.Write("l");
port.Close();
}
}
示例13: CompileScript
static string CompileScript(string scriptFile)
{
string retval = "";
StringBuilder sb = new StringBuilder();
Process myProcess = new Process();
myProcess.StartInfo.FileName = "cscs.exe";
myProcess.StartInfo.Arguments = "/nl /ca \"" + scriptFile + "\"";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
string line = null;
while (null != (line = myProcess.StandardOutput.ReadLine()))
{
sb.Append(line);
sb.Append("\n");
}
myProcess.WaitForExit();
retval = sb.ToString();
string compiledFile = Path.ChangeExtension(scriptFile, ".csc");
if (retval == "" && File.Exists(compiledFile))
File.Delete(compiledFile);
return retval;
}
示例14: Main
public static int Main()
{
Process p;
string strSTDOUT;
p = new Process();
p.StartInfo.FileName = "StringBugNewSyntax.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = null;
p.Start();
p.WaitForExit();
strSTDOUT = p.StandardOutput.ReadToEnd();
strSTDOUT = strSTDOUT.Trim();
if (strSTDOUT.StartsWith(expSTDOUT) && strSTDOUT.EndsWith(expSTDOUT))
{
Console.WriteLine("Pass");
return 100;
}
else
{
Console.WriteLine("Received : [{0}]", strSTDOUT);
Console.WriteLine("Expected Begining: [{0}]", expSTDOUT);
Console.WriteLine("Expected End : [{0}]", expSTDOUT);
Console.WriteLine("FAIL");
return 0;
}
}
示例15: RunProcess
static bool RunProcess (string runtimeEngine, int numLines)
{
string stderr, stdout;
sb = new StringBuilder ();
string program = Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
"output.exe");
Process proc = new Process ();
if (!string.IsNullOrEmpty (runtimeEngine)) {
proc.StartInfo.FileName = runtimeEngine;
proc.StartInfo.Arguments = string.Format (CultureInfo.InvariantCulture,
"\"{0}\" {1}", program, numLines);
} else {
proc.StartInfo.FileName = program;
proc.StartInfo.Arguments = string.Format (CultureInfo.InvariantCulture,
"{0}", numLines);
}
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.OutputDataReceived += new DataReceivedEventHandler (OutputHandler);
proc.Start ();
proc.BeginOutputReadLine ();
stderr = proc.StandardError.ReadToEnd ();
proc.WaitForExit ();
stdout = sb.ToString ();
string expectedResult = "STDOUT => 1" + Environment.NewLine +
"STDOUT => 2" + Environment.NewLine + "STDOUT => 3" +
Environment.NewLine + "STDOUT => 4" + Environment.NewLine +
" " + Environment.NewLine + "STDOUT => 6" + Environment.NewLine +
"STDOUT => 7" + Environment.NewLine + "STDOUT => 8" +
Environment.NewLine + "STDOUT => 9" + Environment.NewLine;
if (stdout != expectedResult) {
Console.WriteLine ("expected:");
Console.WriteLine (expectedResult);
Console.WriteLine ("was:");
Console.WriteLine (stdout);
return false;
}
expectedResult = "STDERR => 1" + Environment.NewLine +
"STDERR => 2" + Environment.NewLine + "STDERR => 3" +
Environment.NewLine + "STDERR => 4" + Environment.NewLine +
" " + Environment.NewLine + "STDERR => 6" + Environment.NewLine +
"STDERR => 7" + Environment.NewLine + "STDERR => 8" +
Environment.NewLine + "STDERR => 9" + Environment.NewLine;
if (stderr != expectedResult) {
Console.WriteLine ("expected:");
Console.WriteLine (expectedResult);
Console.WriteLine ("was:");
Console.WriteLine (stderr);
return false;
}
return true;
}