本文整理汇总了C#中Process类的典型用法代码示例。如果您正苦于以下问题:C# Process类的具体用法?C# Process怎么用?C# Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Process类属于命名空间,在下文中一共展示了Process类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate_Data
public void Generate_Data()
{
if (_Type == QueueType.Process)
{
// use system data to make random processes
System.Diagnostics.Process[] currentProcesses = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in currentProcesses)
{
Process insert = new Process(Make_Start_Time(), Make_Burst_Time(), Make_Priority());
insert.ProcessID = p.ProcessName;
insert.Size = p.PeakPagedMemorySize64;
//insert.StartTime =
_ProcessList.Add(insert);
}
// now that all processes are in list, reorder againsts arival time
_ProcessList = new Collection<Process>(_ProcessList.OrderBy(o => o.StartTime).ToList());
}
else if (_Type == QueueType.Memory_Paging)
{
// here we need generated information regarding blocks of data, so for random fun, lets use frequent things
string localFolder = Environment.GetFolderPath(Environment.SpecialFolder.Recent);
DirectoryInfo recentFolder = new DirectoryInfo(localFolder);
_Files = recentFolder.GetFiles();
}
}
示例2: OpenGitBash
public static void OpenGitBash()
{
string projectDir = Application.dataPath + "/../";
string gitDir = projectDir + ".git";
#if !UNITY_EDITOR_WIN
Debug.LogError("Only supported in Windows Editor");
#else
if (!Directory.Exists(gitDir)) {
Debug.LogError("No git repo for this project");
return;
}
string gitBash = null;
if (File.Exists(GIT_BASH_64)) {
gitBash = GIT_BASH_64;
} else if (File.Exists(GIT_BASH_32)) {
gitBash = GIT_BASH_32;
} else {
Debug.LogError("Couldn't find Git Bash");
return;
}
Process foo = new Process {
StartInfo = {
FileName = gitBash,
WorkingDirectory = projectDir
}
};
foo.Start();
#endif
}
示例3: 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;
}
}
示例4: Initialize
public void Initialize(Process process) {
var connection = process.OutputConnection;
var entity = process.OutputConnection.TflBatchEntity(process.Name);
new ElasticSearchEntityDropper().Drop(connection, entity);
process.Logger.Info( "Initialized TrAnSfOrMaLiZeR {0} connection.", process.OutputConnection.Name);
}
示例5: Main
static void Main()
{
try
{
string[] words = { "start", "Start - Game", "end - GameStart" };
string txtFile = @"..\..\textFile.txt";
string outputFile = @"..\..\finish.txt";
RandomizationFile(words, txtFile);
ChangingWordInFile(txtFile, outputFile);
Process openfile = new Process();
openfile.StartInfo.FileName = txtFile;
openfile.Start();
openfile.StartInfo.FileName = outputFile;
openfile.Start();
}
catch (FileNotFoundException FNFE)
{
Console.WriteLine(FNFE.Message);
}
catch (NullReferenceException NRE)
{
Console.WriteLine(NRE.Message);
}
catch (ArgumentNullException ANE)
{
Console.WriteLine(ANE.Message);
}
finally
{
Console.WriteLine("Good Bye");
}
}
示例6: CompressFiles
//使用winrar压缩文件
public static void CompressFiles(string rarPath, ArrayList fileArray)
{
string rar;
RegistryKey reg;
object obj;
string info;
ProcessStartInfo startInfo;
Process rarProcess;
try
{
reg = Registry.ClassesRoot.OpenSubKey("Applications\\WinRAR.exe\\Shell\\Open\\Command");
obj = reg.GetValue("");
rar = obj.ToString();
reg.Close();
rar = rar.Substring(1, rar.Length - 7);
info = " a -as -r -EP1 " + rarPath;
foreach (string filepath in fileArray)
info += " " + filepath;
startInfo = new ProcessStartInfo();
startInfo.FileName = rar;
startInfo.Arguments = info;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
rarProcess = new Process();
rarProcess.StartInfo = startInfo;
rarProcess.Start();
}
catch
{
}
}
示例7: Kill
public void Kill()
{
const int inneriterations = 500;
foreach (var iteration in Benchmark.Iterations)
{
// Create several processes to test on
Process[] processes = new Process[inneriterations];
for (int i = 0; i < inneriterations; i++)
{
processes[i] = CreateProcessLong();
processes[i].Start();
}
// Begin Testing - Kill all of the processes
using (iteration.StartMeasurement())
for (int i = 0; i < inneriterations; i++)
processes[i].Kill();
// Cleanup the processes
foreach (Process proc in processes)
{
proc.WaitForExit();
proc.Dispose();
}
}
}
示例8: IndexInterleaveAbstract
public IndexInterleaveAbstract(Process processBase, Expression range)
{
Processes = new List<Process>();
Processes.Add(processBase);
RangeExpression = range;
}
示例9: Sleepify
public void Sleepify(Process p, long duration)
{
p.timeToWake = DateTime.Now.AddMilliseconds(duration).Ticks;
p.State = ProcessState.Sleeping;
// Put them in makeshift queue, where last element = front of the queue
timerWaiting.InsertSorted(p, (p1, p2) => (int)(p2.timeToWake - p1.timeToWake));
}
示例10: Magellan
public Magellan()
{
MsgDelegate = new MsgRecv(this.MsgRecvMethod);
this.FormClosing += new FormClosingEventHandler(FormClosingMethod);
ArrayList conf = ReadConfig();
sph = new SerialPortHandler[conf.Count];
for(int i = 0; i < conf.Count; i++){
string port = ((string[])conf[i])[0];
string module = ((string[])conf[i])[1];
Type t = Type.GetType("SPH."+module+", SPH, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
sph[i] = (SerialPortHandler)Activator.CreateInstance(t, new Object[]{ port });
sph[i].SetParent(this);
}
MonitorSerialPorts();
browser_window = Process.Start("iexplore.exe",
"http://localhost/");
u = new UDPMsgBox(9450);
u.SetParent(this);
u.My_Thread.Start();
}
示例11: RunCommand
private static CommandExecResult RunCommand(String processName, String args)
{
Process p = new Process();
string output = "";
p.StartInfo.FileName = processName;
p.StartInfo.WorkingDirectory = "..";
p.StartInfo.Arguments = args;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
try
{
p.Start();
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
System.Environment.Exit(1);
}
CommandExecResult cmdResult;
cmdResult.exitCode = p.ExitCode;
cmdResult.stdOut = output;
return cmdResult;
}
示例12: Main
static void Main()
{
try
{
string[] words = { "testAmigo", "middle - Game", "test" };
string txtFile = @"..\..\textFile.txt";
RandomizationFile(words, txtFile);
DeletesText(txtFile);
Process openfile = new Process();
openfile.StartInfo.FileName = txtFile;
openfile.Start();
}
catch (FileNotFoundException FNFE)
{
Console.WriteLine(FNFE.Message);
}
catch (NullReferenceException NRE)
{
Console.WriteLine(NRE.Message);
}
catch (ArgumentNullException ANE)
{
Console.WriteLine(ANE.Message);
}
catch (IOException IOE)
{
Console.WriteLine(IOE.Message);
}
finally
{
Console.WriteLine("Good Bye");
}
}
示例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: ExecuteMethod_ObtainLockRemoveFromContainerAndDeleteProcess
public static void ExecuteMethod_ObtainLockRemoveFromContainerAndDeleteProcess(string processID, Process process, ProcessContainer ownerProcessContainer)
{
if (process == null)
{
if (ownerProcessContainer != null && ownerProcessContainer.ProcessIDs != null)
{
ownerProcessContainer.ProcessIDs.Remove(processID);
ownerProcessContainer.StoreInformation();
}
}
else
{
string lockEtag = process.ObtainLockOnObject();
if (lockEtag == null)
return;
try
{
if (ownerProcessContainer != null)
{
ownerProcessContainer.ProcessIDs.Remove(process.ID);
ownerProcessContainer.StoreInformation();
}
process.DeleteInformationObject();
}
finally
{
process.ReleaseLockOnObject(lockEtag);
}
}
}
示例15: StartSleepKillWait
protected void StartSleepKillWait(Process p)
{
p.Start();
Thread.Sleep(50);
p.Kill();
Assert.True(p.WaitForExit(WaitInMS));
}