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

C# ProcessInfo类代码示例

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

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



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

示例1: ProcessInfo_TestEqualishWorksAlwaysReturnsFalseForDifferentProcesses

        public void ProcessInfo_TestEqualishWorksAlwaysReturnsFalseForDifferentProcesses()
        {
            var info1 = new ProcessInfo("process.exe", "TestDocument.doc *");
            var info2 = new ProcessInfo("process2.exe", "TestDocument.doc");

            info1.IsEqualishTo(info2).Should().BeFalse("because they're different processes");
        }
开发者ID:petedishman,项目名称:TimeTracker,代码行数:7,代码来源:ProcessInfoTests.cs


示例2: ProcessInfo_TestEverything

        public void ProcessInfo_TestEverything()
        {
            ProcessInfo p1 = new ProcessInfo();
            Assert.AreEqual(0, p1.ProcessId);
            Assert.AreEqual(ProcessInfo.ProcessType.Unknown, p1.Type);
            Assert.IsNull(p1.EndPoint);
            Assert.IsNull(p1.Label);
            Assert.AreEqual(ProcessInfo.StatusCode.Unknown, p1.Status);
            Assert.IsNull(p1.AliveTimestamp);

            PublicEndPoint ep1 = new PublicEndPoint() { Host = "swcwin.serv.usu.edu", Port = 32541 };
            DateTime t1 = DateTime.Now;
            ProcessInfo p2 = new ProcessInfo()
                {
                    ProcessId = 10,
                    Type = ProcessInfo.ProcessType.Player,
                    EndPoint = ep1,
                    Label = "Test Process",
                    Status = ProcessInfo.StatusCode.Initializing,
                    AliveTimestamp = t1
                };
            Assert.AreEqual(10, p2.ProcessId);
            Assert.AreEqual(ProcessInfo.ProcessType.Player, p2.Type);
            Assert.AreEqual(ep1, p2.EndPoint);
            Assert.AreEqual("Test Process", p2.Label);
            Assert.AreEqual(ProcessInfo.StatusCode.Initializing, p2.Status);
            Assert.AreEqual("Initializing", p2.StatusString);
            Assert.AreEqual(t1, p2.AliveTimestamp);
        }
开发者ID:JeffHemming,项目名称:DSoak_First,代码行数:29,代码来源:ProcessInfoTester.cs


示例3: ProcessMonitor

 public ProcessMonitor(Process p)
 {
     m_process = p;
     m_info = new ProcessInfo(p);
     UpdateDeltas();
     //m_cpucounter = new PerformanceCounter("Processor", "% Processor Time", GetPerformanceCounterProcessName(m_process.Id), true);
 }
开发者ID:janwilmans,项目名称:ProcessMonitor,代码行数:7,代码来源:ProcessMonitor.cs


示例4: StreamEncodingCanBeChanged

 public void StreamEncodingCanBeChanged()
 {
     var info = new ProcessInfo("somewhere");
     var encoding = Encoding.UTF32;
     info.StreamEncoding = encoding;
     Assert.AreEqual(encoding, info.StreamEncoding);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:ProcessInfoTests.cs


示例5: StandardInputContentCanBeChanged

 public void StandardInputContentCanBeChanged()
 {
     var info = new ProcessInfo("somewhere");
     var expected = "some data to pass in";
     info.StandardInputContent = expected;
     Assert.AreEqual(expected, info.StandardInputContent);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:ProcessInfoTests.cs


示例6: Show

        public void Show(ProcessInfo process, string whatsHigh)
        {
            this._Process = process;

            this.Text = "Warning! Process taking high " + whatsHigh;
            this.TitleLabel.Text = "The following process is taking high " + whatsHigh + " and should be closed:";
            this.ProcessNameLabel.Text = process.Title;
            this.PostponeButton.Text = string.Format("Postpone {0} mins", Settings.Default.Default_Postpone_Time.TotalMinutes);
            this.CPULabel.Text = process.CpuUsage + "%";
            this.MemoryLabel.Text = (process.WorkingSet / 1048576) + " MB";
            try
            {
                Process realProcess = Process.GetProcessById(process.Id);
                this.ProcessNameLabel.Text = realProcess.MainWindowTitle;

            }
            catch
            {
            }

            this.Show();
            this.Refresh();
            this.TopMost = true;

            this.DummyTextBox.Focus();
        }
开发者ID:modulexcite,项目名称:cpualert,代码行数:26,代码来源:KillProcessForm.cs


示例7: MinimalConstructorSetsFilename

 public void MinimalConstructorSetsFilename()
 {
     var filename = "nameoffile";
     var info = new ProcessInfo(filename);
     Assert.AreEqual(filename, info.FileName);
     Assert.AreEqual(2, info.TimeOut.Minutes);
 }
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:7,代码来源:ProcessInfoTests.cs


示例8: CreateProcess

        public static System.Diagnostics.Process CreateProcess(string path, string args, string currentDirectory)
        {
            if (!File.Exists(path))
            {
                throw new ArgumentException("File does not exist");
            }
            ProcessInfo proc = new ProcessInfo();
            try
            {
                var inf = new StartupInfo();

                inf.cb = (uint)Marshal.SizeOf(typeof(StartupInfo));
                var cmd = path;
                if(!string.IsNullOrWhiteSpace(args))
                {
                    cmd += " " + args;
                }
                if (!CreateProcess(null, cmd, IntPtr.Zero, IntPtr.Zero, false, CREATE_BREAKAWAY_FROM_JOB | CREATE_NO_WINDOW, IntPtr.Zero, currentDirectory, ref inf, out proc))
                {
                    throw new InvalidOperationException("Couldn't create process");
                }

                return System.Diagnostics.Process.GetProcessById(proc.ProcessId);
            }
            finally
            {
                if (proc.hProcess != IntPtr.Zero)
                {
                    Interop.CloseHandle(proc.hProcess);
                }
            }


        }
开发者ID:Zawulon,项目名称:JobObject.Net,代码行数:34,代码来源:Process.cs


示例9: ShouldNotUseATimeoutIfTimeoutSetToInfiniteOnProcessInfo

		public void ShouldNotUseATimeoutIfTimeoutSetToInfiniteOnProcessInfo()
		{
			ProcessInfo processInfo = new ProcessInfo("cmd.exe", "/C @echo Hello World");
			processInfo.TimeOut = ProcessInfo.InfiniteTimeout;
			ProcessResult result = executor.Execute(processInfo);
			AssertProcessExitsSuccessfully(result);
			Assert.AreEqual("Hello World", result.StandardOutput.Trim());			
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:8,代码来源:ProcessExecutorTest.cs


示例10: ProcessInfo_TestEqualishWorksWithUnsavedDocumentMarkers

        public void ProcessInfo_TestEqualishWorksWithUnsavedDocumentMarkers()
        {
            var processName = "process.exe";
            var info1 = new ProcessInfo(processName, "TestDocument.doc *");
            var info2 = new ProcessInfo(processName, "TestDocument.doc");

            info1.IsEqualishTo(info2).Should().BeTrue("because the process name is the same and the window title is basically the same!");
        }
开发者ID:petedishman,项目名称:TimeTracker,代码行数:8,代码来源:ProcessInfoTests.cs


示例11: IfStandardInputContentIsSetThenStandardInputIsRedirected

		public void IfStandardInputContentIsSetThenStandardInputIsRedirected()
		{
			ProcessInfo info = new ProcessInfo("temp");
			info.StandardInputContent = "Some content";

			Process process = info.CreateProcess();
			Assert.IsTrue(process.StartInfo.RedirectStandardInput);
			Assert.IsTrue(!process.StartInfo.UseShellExecute);
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:9,代码来源:ProcessInfoTest.cs


示例12: SetEnvironmentVariables

		public void SetEnvironmentVariables()
		{
			ProcessInfo processInfo = new ProcessInfo("cmd.exe", "/C set foo", null);
			processInfo.EnvironmentVariables["foo"] = "bar";
			ProcessResult result = executor.Execute(processInfo);

			AssertProcessExitsSuccessfully(result);
			Assert.AreEqual("foo=bar\r\n", result.StandardOutput);
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:9,代码来源:ProcessExecutorTest.cs


示例13: WriteToStandardInput

 private static void WriteToStandardInput(Process process, ProcessInfo processInfo)
 {
     if (process.StartInfo.RedirectStandardInput)
     {
         process.StandardInput.Write(processInfo.StandardInputContent);
         process.StandardInput.Flush();
         process.StandardInput.Close();
     }
 }
开发者ID:bsimser,项目名称:treesurgeon,代码行数:9,代码来源:ProcessExecutor.cs


示例14: ProcessInfo_ConstructorShouldSetProperties

        public void ProcessInfo_ConstructorShouldSetProperties()
        {
            var name = "process.exe";
            var title = "window title";
            var info = new ProcessInfo(name, title);

            info.Name.Should().BeEquivalentTo(name);
            info.WindowTitle.Should().BeEquivalentTo(title);
        }
开发者ID:petedishman,项目名称:TimeTracker,代码行数:9,代码来源:ProcessInfoTests.cs


示例15: ForceProcessTimeoutBecauseTargetIsNonTerminating

		public void ForceProcessTimeoutBecauseTargetIsNonTerminating()
		{
			ProcessInfo processInfo = new ProcessInfo("sleeper.exe");
			processInfo.TimeOut = 100;
			ProcessResult result = executor.Execute(processInfo);

			Assert.IsTrue(result.TimedOut, "process did not time out, but it should have.");
			Assert.IsNotNull(result.StandardOutput, "some output should have been produced");
			AssertProcessExitsWithFailure(result);
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:10,代码来源:ProcessExecutorTest.cs


示例16: IfExecutableIsFoundInWorkingDirectoryThenUseCombinedPathAsExecutablePath

		public void IfExecutableIsFoundInWorkingDirectoryThenUseCombinedPathAsExecutablePath()
		{
			string workingDir = TempFileUtil.CreateTempDir("working");
			string executablePath = TempFileUtil.CreateTempFile("working", "myExecutable");

			ProcessInfo infoWithoutPathQualifiedExecutable = new ProcessInfo("myExecutable", "", workingDir);
			ProcessInfo infoWithPreQualifiedExecutable = new ProcessInfo(executablePath, "", workingDir);

			Assert.AreEqual(infoWithPreQualifiedExecutable, infoWithoutPathQualifiedExecutable);
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:10,代码来源:ProcessInfoTest.cs


示例17: AppStatus

 public AppStatus(InstallDirectoryItem appInstallation, string iconUrl, ProcessInfo processInfo, string error)
 {
     Id = appInstallation.PackageId;
     Version = appInstallation.PackageVersion;
     Instance = appInstallation.Instance;
     FullName = $"{appInstallation.PackageId}.{appInstallation.PackageVersion}@{appInstallation.Instance}".TrimEnd('@');
     IconUrl = iconUrl;
     ProcessInfo = processInfo;
     Error = error;
 }
开发者ID:InfinniPlatform,项目名称:Infinni.Node,代码行数:10,代码来源:ProcessHelper.cs


示例18: ProcessInfo_TestEqualityWorks

        public void ProcessInfo_TestEqualityWorks()
        {
            var info1 = new ProcessInfo("process.exe", "window title");
            var info2 = new ProcessInfo("process.exe", "window title");
            var info3 = new ProcessInfo("process.exe", "different window title");
            var info4 = new ProcessInfo("proc.exe", "window title");

            info1.Equals(info2).Should().BeTrue("because the two objects have the same process/window title");
            info1.Equals(info3).Should().BeFalse("because the window titles are different");
            info1.Equals(info4).Should().BeFalse("because the process titles are different");
        }
开发者ID:petedishman,项目名称:TimeTracker,代码行数:11,代码来源:ProcessInfoTests.cs


示例19: Player

 public Player()
 {
     Label = "Drew's Player";
     MyProcessInfo = new ProcessInfo()
     {
         Status = ProcessInfo.StatusCode.NotInitialized,
         Label = Label,
         Type = ProcessInfo.ProcessType.Player
     };
     CleanupSession();
 }
开发者ID:drewtorg,项目名称:MyDSoak,代码行数:11,代码来源:Player.cs


示例20: CreateProcess

 static extern bool CreateProcess(
     string lpApplicationName,
     string lpCommandLine, 
     ref SECURITY_ATTRIBUTES lpProcessAttributes,
     ref SECURITY_ATTRIBUTES lpThreadAttributes, 
     bool bInheritHandles,
     uint dwCreationFlags, 
     IntPtr lpEnvironment, 
     string lpCurrentDirectory,
     [In] ref StartupInfo lpStartupInfo,
     out ProcessInfo lpProcessInformation);
开发者ID:stevehjohn,项目名称:Hub,代码行数:11,代码来源:EmbeddedProcessOLD.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ProcessPriorityClass类代码示例发布时间:2022-05-24
下一篇:
C# ProcessHandle类代码示例发布时间: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