当前位置: 首页>>代码示例>>C#>>正文


C# Process类代码示例

本文整理汇总了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();
            }
        }
开发者ID:hapex,项目名称:OS-Simulator,代码行数:28,代码来源:Queue.cs

示例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
        }
开发者ID:petereichinger,项目名称:unity-helpers,代码行数:30,代码来源:OpenGitBashTool.cs

示例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;
		}
	}
开发者ID:Profit0004,项目名称:mono,代码行数:35,代码来源:bug-17537.cs

示例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);
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:7,代码来源:ElasticSearchTflWriter.cs

示例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");
        }
    }
开发者ID:joro1881,项目名称:CSharpProgramming,代码行数:35,代码来源:Modifying07.cs

示例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
        {

        }
    }
开发者ID:tedi3231,项目名称:DMCProject,代码行数:32,代码来源:common.cs

示例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();
                }
            }
        }
开发者ID:JonHanna,项目名称:corefx,代码行数:26,代码来源:Perf.Process.cs

示例8: IndexInterleaveAbstract

        public IndexInterleaveAbstract(Process processBase, Expression range)
        {
            Processes = new List<Process>();
            Processes.Add(processBase);

            RangeExpression = range;
        }
开发者ID:nhannhan159,项目名称:PAT,代码行数:7,代码来源:IndexInterleaveAbstract.cs

示例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));
 }
开发者ID:andyhebear,项目名称:kitsune,代码行数:7,代码来源:VM.cs

示例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();
    }
开发者ID:joelbrock,项目名称:NOFC_CORE,代码行数:25,代码来源:MagellanWithoutWebBrowserObject.cs

示例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;
    }
开发者ID:jsieczak,项目名称:password-hashing,代码行数:29,代码来源:CSharpAndPHPCompatibility.cs

示例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");
        }
    }
开发者ID:joro1881,项目名称:CSharpProgramming,代码行数:34,代码来源:DeletesTextPrefixTest.cs

示例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;
    }
开发者ID:Diullei,项目名称:Storm,代码行数:30,代码来源:verify.cs

示例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);
         }
     }
 }
开发者ID:kallex,项目名称:Caloom,代码行数:30,代码来源:DeleteProcessImplementation.cs

示例15: StartSleepKillWait

 protected void StartSleepKillWait(Process p)
 {
     p.Start();
     Thread.Sleep(50);
     p.Kill();
     Assert.True(p.WaitForExit(WaitInMS));
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:ProcessTestBase.cs


注:本文中的Process类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。