Skip to content

Latest commit

 

History

History
39 lines (36 loc) · 1.43 KB

how-to-determine-if-shutdown-has-started-cpp-cli.md

File metadata and controls

39 lines (36 loc) · 1.43 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
How to: Determine if Shutdown Has Started (C++/CLI) | Microsoft Docs
11/04/2016
cpp-windows
article
C++
.NET Framework, shutdown
shutdown
termination
applications [C++], shutdown
a8d39731-dea8-4f0a-96b7-2a5de09b21d7
9
mikeblome
mblome
ghogen

How to: Determine if Shutdown Has Started (C++/CLI)

The following code example demonstrates how to determine whether the application or the .NET Framework is currently terminating. This is useful for accessing static elements in the .NET Framework because, during shutdown, these constructs are finalized by the system and cannot be reliably used. By checking the xref:System.Environment.HasShutdownStarted%2A property first, you can avoid potential failures by not accessing these elements.

Example

// check_shutdown.cpp  
// compile with: /clr  
using namespace System;  
int main()   
{  
   if (Environment::HasShutdownStarted)  
      Console::WriteLine("Shutting down.");  
   else  
      Console::WriteLine("Not shutting down.");  
   return 0;  
}  

See Also

Windows Operations (C++/CLI)
.NET Programming with C++/CLI (Visual C++)