本文整理汇总了C#中System.Diagnostics.Process.?.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Process.?.Dispose方法的具体用法?C# Process.?.Dispose怎么用?C# Process.?.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.?.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckCompiler
private bool CheckCompiler()
{
CheckCompilerBinary();
idleTimer?.Destroy();
if (BinaryPath == null) return false;
if (process != null && !process.HasExited) return true;
PurgeOldLogs();
Shutdown();
var args = new [] {"/service", "/logPath:" + EscapeArgument(Interface.Oxide.LogDirectory)};
try
{
process = new Process
{
StartInfo =
{
FileName = BinaryPath,
Arguments = string.Join(" ", args),
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true
},
EnableRaisingEvents = true
};
string path;
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.Win32NT:
var currentPath = process.StartInfo.EnvironmentVariables["PATH"] ?? Environment.GetEnvironmentVariable("PATH");
path = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, "x86")}";
var newPath = string.IsNullOrEmpty(currentPath) ? path : $"{currentPath}{Path.PathSeparator}{path}";
process.StartInfo.EnvironmentVariables["PATH"] = newPath;
break;
case PlatformID.Unix:
case PlatformID.MacOSX:
var currentLdLibraryPath = process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] ?? Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
path = $"{Path.Combine(Interface.Oxide.ExtensionDirectory, IntPtr.Size == 8 ? "x64" : "x86")}";
var newLdLibraryPath = string.IsNullOrEmpty(currentLdLibraryPath) ? path : $"{currentLdLibraryPath}{Path.PathSeparator}{path}";
process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] = newLdLibraryPath;
break;
}
process.Exited += OnProcessExited;
process.Start();
}
catch (Exception ex)
{
process?.Dispose();
process = null;
Interface.Oxide.LogException("Exception while starting compiler: ", ex);
if (ex.GetBaseException() != ex) Interface.Oxide.LogException("BaseException: ", ex.GetBaseException());
}
if (process == null) return false;
client = new ObjectStreamClient<CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
client.Message += OnMessage;
client.Error += OnError;
client.Start();
return true;
}
示例2: CheckCompiler
private bool CheckCompiler()
{
CheckCompilerBinary();
idleTimer?.Destroy();
if (BinaryPath == null) return false;
if (process != null && !process.HasExited) return true;
PurgeOldLogs();
Shutdown();
var args = new [] {"/service", "/logPath:" + EscapeArgument(Interface.Oxide.LogDirectory)};
try
{
process = new Process
{
StartInfo =
{
FileName = BinaryPath,
Arguments = string.Join(" ", args),
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true
},
EnableRaisingEvents = true
};
process.Exited += OnProcessExited;
process.Start();
}
catch (Exception ex)
{
process?.Dispose();
process = null;
Interface.Oxide.LogException("Exception while starting compiler: ", ex);
if (ex.GetBaseException() != ex) Interface.Oxide.LogException("BaseException: ", ex.GetBaseException());
}
if (process == null) return false;
client = new ObjectStreamClient<CompilerMessage>(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
client.Message += OnMessage;
client.Error += OnError;
client.Start();
return true;
}