public void TestCommonPriorityAndTimeProperties()
{
ProcessThreadCollection threadCollection = _process.Threads;
Assert.True(threadCollection.Count > 0);
ProcessThread thread = threadCollection[0];
try
{
if (ThreadState.Terminated != thread.ThreadState)
{
Assert.True(thread.Id >= 0);
Assert.Equal(_process.BasePriority, thread.BasePriority);
Assert.True(thread.CurrentPriority >= 0);
Assert.True(thread.PrivilegedProcessorTime.TotalSeconds >= 0);
Assert.True(thread.UserProcessorTime.TotalSeconds >= 0);
Assert.True(thread.TotalProcessorTime.TotalSeconds >= 0);
}
}
catch (Exception e) when (e is Win32Exception || e is InvalidOperationException)
{
// Win32Exception is thrown when getting threadinfo fails, or
// InvalidOperationException if it fails because the thread already exited.
}
}