65.9K
CodeProject is changing. Read more.
Home

Does Your App Know Where it's Running

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.78/5 (8 votes)

Feb 3, 2011

CPOL
viewsIcon

10689

I use the following to insert pauses into console apps when they are vs hosted. In fact it's the final lines in my standard template for a console app to ensure that the console stays visible until I dismiss it.if (AppDomain.CurrentDomain.FriendlyName.EndsWith("vshost.exe",...

I use the following to insert pauses into console apps when they are vs hosted. In fact it's the final lines in my standard template for a console app to ensure that the console stays visible until I dismiss it.
if (AppDomain.CurrentDomain.FriendlyName.EndsWith("vshost.exe", StringComparison.OrdinalIgnoreCase)) {
  // you are vs hosted
  Console.WriteLine("Press a key to continue...");
  Console.ReadLine();
}
Alan.