Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
How to: Determine the User Interactive State

How to: Determine the User Interactive State (C++/CLI)

The following code example demonstrates how to determine whether code is being run in a user-interactive context. If UserInteractive is false, then the code is running as a service process or from inside a Web application, in which case you should not attempt to interact with the user.

// user_interactive.cpp
// compile with: /clr
using namespace System;

int main() 
   if ( Environment::UserInteractive )
      Console::WriteLine("User interactive");
   return 0;

Community Additions

© 2015 Microsoft