• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Process类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Process的典型用法代码示例。如果您正苦于以下问题:C# Process类的具体用法?C# Process怎么用?C# Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Process类属于命名空间,在下文中一共展示了Process类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: OnPostprocessAllAssets

    static void OnPostprocessAllAssets (string[] ia, string[] da, string[] ma, string[] mfap) {
        // skip if importing dll as already built
        if (Array.IndexOf(ia, "Assets/dll/scripts.dll") > -1) return;

        // setup the process
        var p = new Process();
        p.StartInfo.FileName = "/usr/bin/make";
        p.StartInfo.Arguments = "-C " + System.IO.Directory.GetCurrentDirectory() + "/Assets/Editor/";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;

        // assign events
        p.OutputDataReceived +=
            new DataReceivedEventHandler((o, e) => {
                if (e.Data != null) {
                    UnityEngine.Debug.Log(e.Data);
                }
            });
        p.ErrorDataReceived +=
            new DataReceivedEventHandler((o, e) => {
                if (e.Data != null) {
                    UnityEngine.Debug.LogError(e.Data);
                }
            });

        // start to process and output/error reading
        p.Start();
        p.BeginOutputReadLine();
        p.BeginErrorReadLine();
    }
开发者ID:shockham,项目名称:unity_fsharp_skeleton,代码行数:31,代码来源:BuildFSharp.cs


示例17: 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;
	}
开发者ID:mono,项目名称:gert,代码行数:60,代码来源:test.cs


示例18: menuItemCreateProcess_Click

 private void menuItemCreateProcess_Click(object sender, EventArgs e)
 {
     OpenFileDialog ofDlg = new OpenFileDialog();
     ofDlg.Filter = "可执行文件|*.exe";
     if (ofDlg.ShowDialog() == DialogResult.OK)
     {
         Process newProcess = new Process();
         try
         {
             newProcess.StartInfo.UseShellExecute = false;
             newProcess.StartInfo.FileName = ofDlg.FileName;
             newProcess.StartInfo.CreateNoWindow = true;
             newProcess.Start();
             if (newProcess != null)
             {
                 newProcess.EnableRaisingEvents = true;
                 newProcess.Exited += new EventHandler(OnProcessExited);
                 newProcess.WaitForExit();
             }
             ListAllProcesss();
         }
         catch (ArgumentException ex)
         {
             MessageBox.Show(ex.Message, "参数错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
开发者ID:DanylZhang,项目名称:CurriculumDesign,代码行数:27,代码来源:Form1.cs


示例19: Compile

        /// <summary>
        /// 编译指定目录下的文件
        /// </summary>
        /// <param name="root">源代码目录</param>
        /// <param name="outputDllName">编译输出的dll名称</param>
        /// <param name="references">编译时需要的引用程序集</param>
        public static void Compile(String root, String outputDllName, params String[] references)
        {
            var args = BuildCompileArgs(root, outputDllName, references);
            var cmd = Path.Combine(MonoLocation, "bin/mcs").ToConsistentPath();

            UnityEngine.Debug.Log(String.Format("{0} {1}", cmd, args));

#if UNITY_EDITOR_OSX
            var proc = new Process
            {
                StartInfo =
                {
                    FileName = cmd,
                    Arguments = args,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    RedirectStandardInput = true
                }
            };
#else
            var proc = new Process
            {
                StartInfo =
                {
                    FileName = cmd,
                    Arguments = args,
                    UseShellExecute = true
                }
            };
#endif
            proc.Start();
            proc.WaitForExit();
            proc.Close();
        }
开发者ID:xclouder,项目名称:godbattle,代码行数:41,代码来源:CompileUtility.cs


示例20: ConvertFromUrl

    public void ConvertFromUrl(string url, string file_out, HtmlToPdfConverterOptions options)
    {
        string converter_path = HttpContext.Current.Server.MapPath("~/bin/wkhtmltopdf/wkhtmltopdf.exe");

        string param_options = null;

        if (options != null)
        {
            StringBuilder sb_params = new StringBuilder();

            if (!string.IsNullOrEmpty(options.Orientation)) sb_params.Append(" --orientation ").Append(options.Orientation);
            if (options.PageWidth > 0) sb_params.Append(" --page-width ").Append(options.PageWidth);
            if (options.PageHeight > 0) sb_params.Append(" --page-height ").Append(options.PageHeight);
            if (!string.IsNullOrEmpty(options.PageSize)) sb_params.Append(" --page-size ").Append(options.PageSize);
            if (!string.IsNullOrEmpty(options.CookieName)) sb_params.Append(" --cookie ").Append(options.CookieName).Append(' ').Append(options.CookieValue);

            param_options = sb_params.ToString();
        }

        ProcessStartInfo psi = new ProcessStartInfo(converter_path, string.Format("{0} \"{1}\" \"{2}\"", param_options.Trim(), url, file_out));

        psi.UseShellExecute = false;
        psi.CreateNoWindow = true;

        Process proc = new Process ();
        proc.StartInfo = psi;
        proc.Start();
        proc.WaitForExit();

        //!= 0) throw new Exception(string.Format("Could not generate {0}", file_out));
    }
开发者ID:publichealthcloud,项目名称:absenteesurveillance,代码行数:31,代码来源:HtmlToPdf.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ProcessAccessFlags类代码示例发布时间:2022-05-24
下一篇:
C# Procedure类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap