MutexIndex Property
Collapse the table of content
Expand the table of content

AbandonedMutexException.MutexIndex Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the index of the abandoned mutex that caused the exception, if known.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public int MutexIndex { get; }

Property Value

Type: System.Int32
The index, in the array of wait handles passed to the WaitHandle.WaitAny method, of the Mutex object that represents the abandoned mutex, or –1 if the index of the abandoned mutex could not be determined.

If the exception is thrown on a call to the WaitHandle.WaitAny method, this property returns the index of the abandoned mutex with the lowest index in the array of WaitHandle objects that was passed to WaitAny, or –1 if the abandoned mutex could not be identified. If the exception is thrown on a call to WaitOne or WaitAll, this property always returns –1.

The following code example executes a thread that abandons five mutexes. The abandoned mutexes are used to demonstrate the effects on the WaitHandle.WaitOne, WaitAny, and WaitAll method calls. The value of the MutexIndex property is displayed for the WaitAny call.

NoteNote:

The call to WaitAny is interrupted by one of the abandoned mutexes. The other abandoned mutex could still cause an AbandonedMutexException to be thrown by subsequent wait methods.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2016 Microsoft