MI_Session_Close function

Closes a session and releases all associated memory.


 MI_INLINE MI_Result MI_Session_Close(
  _Inout_  MI_Session *session,
  _In_opt_ void       *completionContext,
  _Inout_  void (MI_CALL *completionCallback)(_In_opt_ void *completionContext)


session [in, out]

Session handle returned from MI_Application_NewSession.

completionContext [in, optional]

Optional parameter to be returned through the completionCallback callback.

completionCallback [in, out]

Optional callback to make the session close asynchronous. (If this value is NULL, then the close call is synchronous.) If the MI_Session_Close is called from a callback the completion callback must be specified. Not doing so can result in a deadlock.

completionContext [in, optional]

Return value

A value of the MI_Result enumeration that specifies the function return code. This can be one of the following codes.


The operation succeeded.


There is not enough memory to complete the request.


One or more parameters passed to the function were not valid.


A failure not covered by other MI_Result error codes.


Closing a session will cause all operations that are currently running to be canceled. Canceling operations will cause asynchronous operation callbacks to be called (with the final result of an MI_Operation_Get* function call's moreResults parameter equal to MI_FALSE, although more than one result may be delivered before this happens). Not closing all operation handles that were created with the current session will cause the closing of the session to stop responding for synchronous calls and the asynchronous callback will not be called. Operation and session handles not fully closed will cause the application handle to stop responding during shutdown.


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012


Windows Management Framework 3.0 on Windows Server 2008 R2 with SP1, Windows 7 with SP1, and Windows Server 2008 with SP2