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


C# System.Diagnostics.Select方法代码示例

本文整理汇总了C#中System.Diagnostics.Select方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Select方法的具体用法?C# System.Diagnostics.Select怎么用?C# System.Diagnostics.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics的用法示例。


在下文中一共展示了System.Diagnostics.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FiltersOutMissingProcesses

            public void FiltersOutMissingProcesses()
            {
                var processes = new[]
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var processIds = processes.Select(p => p.Id).ToList();
                    processIds.Add(1);

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                        x => Assert.Equal(processes[0].Id, x.Id),
                        x => Assert.Equal(processes[1].Id, x.Id)
                    );
                }
                finally
                {
                    foreach (var p in processes)
                        p.Kill();
                }
            }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:28,代码来源:ProcessHelperTest.cs

示例2: InitiatizeCategory

		void InitiatizeCategory()
		{
			try
			{
				var counters = new[]
					{
						ConsumerThreadCount,
						ReceiveThreadCount,
						ReceiveRate,
						PublishRate,
						SendRate,
						ReceiveCount,
						PublishCount,
						SentCount,
						ConsumerDuration,
						ConsumerDurationBase,
						ReceiveDuration,
						ReceiveDurationBase,
						PublishDuration,
						PublishDurationBase,
					};

				if (!PerformanceCounterCategory.Exists(CategoryName))
				{
					PerformanceCounterCategory.Create(
						CategoryName,
						CategoryHelp,
						PerformanceCounterCategoryType.MultiInstance,
						new CounterCreationDataCollection(counters.Select(x => (CounterCreationData) x).ToArray()));

					return;
				}

				int missing = counters
					.Where(counter => !PerformanceCounterCategory.CounterExists(counter.Name, CategoryName))
					.Count();

				if (missing > 0)
				{
					PerformanceCounterCategory.Delete(CategoryName);

					PerformanceCounterCategory.Create(
						CategoryName,
						CategoryHelp,
						PerformanceCounterCategoryType.MultiInstance,
						new CounterCreationDataCollection(counters.Select(x => (CounterCreationData) x).ToArray()));
				}
			}
			catch (SecurityException)
			{
                //swallow the exception because having these is NOT critical

			    var msg =
			        "Unable to create performance counter category (Category: {0})" +
                    "\nTry running the program in the Administrator role to set these up." +
                    "\n**Hey, this just means you aren't admin or don't have/want perf counter support**"
			            .FormatWith(CategoryName);
				_log.Warn(msg);
			}
		}
开发者ID:cstick,项目名称:MassTransit,代码行数:60,代码来源:ServiceBusPerformanceCounters.cs

示例3: InitiatizeCategory

		void InitiatizeCategory()
		{
			try
			{
				var counters = new[]
					{
						ConsumerThreadCount,
						ReceiveThreadCount,
						ReceiveRate,
						PublishRate,
						SendRate,
						ReceiveCount,
						PublishCount,
						SentCount,
						ConsumerDuration,
						ConsumerDurationBase,
						ReceiveDuration,
						ReceiveDurationBase,
						PublishDuration,
						PublishDurationBase,
					};

				if (!PerformanceCounterCategory.Exists(CategoryName))
				{
					PerformanceCounterCategory.Create(
						CategoryName,
						CategoryHelp,
						PerformanceCounterCategoryType.MultiInstance,
						new CounterCreationDataCollection(counters.Select(x => (CounterCreationData) x).ToArray()));

					return;
				}

				int missing = counters
					.Where(counter => !PerformanceCounterCategory.CounterExists(counter.Name, CategoryName))
					.Count();

				if (missing > 0)
				{
					PerformanceCounterCategory.Delete(CategoryName);

					PerformanceCounterCategory.Create(
						CategoryName,
						CategoryHelp,
						PerformanceCounterCategoryType.MultiInstance,
						new CounterCreationDataCollection(counters.Select(x => (CounterCreationData) x).ToArray()));
				}
			}
			catch (SecurityException ex)
			{
				_log.Error("Unable to create performance counter category (Category: {0})\nTry running the program in the Administrator role to set these up.".FormatWith(CategoryName), ex);
			}
		}
开发者ID:jimitndiaye,项目名称:MassTransit,代码行数:53,代码来源:ServiceBusPerformanceCounters.cs

示例4: ReturnsProcesses

            public void ReturnsProcesses()
            {
                var processes = new []
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                        x => Assert.Equal(processes[0].Id, x.Id),
                        x => Assert.Equal(processes[1].Id, x.Id)
                    );
                }
                finally
                {
                    foreach (var p in processes)
                        p.Kill();
                }
            }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:25,代码来源:ProcessHelperTest.cs


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