本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}