
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Looking at Your Runtime Environment and Seeing What You Can Do About It
|
485
Console.WriteLine("\tMachine NetBIOS Name: {0}",Environment.MachineName);
Console.WriteLine("\tOS Version Information: {0}",Environment.OSVersion.
VersionString);
Console.WriteLine("\tNumber of processors: {0}",Environment.ProcessorCount);
To see the current call stack, use the StackTrace property:
Console.WriteLine("\tCurrent Stack Trace: {0}",Environment.StackTrace);
For information about the current user and thread, the UserDomainName,
UserInteractive, and UserName properties do the job:
Console.WriteLine("\tCurrent User Domain Name: {0}",Environment.UserDomainName);
Console.WriteLine("\tIs this an interactive user process?: {0}",Environment.
UserInteractive);
Thread.CurrentThread.Name = "Main thread";
Console.WriteLine("\tUser who started Thread ({0}): {1}",Thread.CurrentThread.Name,
Environment.UserName);
Finally, the CLR version and amount of physical memory being used by the process
are available in the
Version and WorkingSet properties:
Console.WriteLine("\tCLR Version this code is running in: {0}",Environment.Version);
Console.WriteLine("\tAmount of physical memory used by this working set: {0}",
Environment.WorkingSet);
Discussion
Adding code to your programs for troubleshooting potential customer issues ...