Show / Hide Table of Contents

Class WindowsMutex

Provides Windows-specific API calls for cross-process Mutexes.

Inheritance
Object
WindowsMutex
Namespace: NanoByte.Common.Native
Assembly: NanoByte.Common.dll
Syntax
public static class WindowsMutex : Object

Methods

Close(IntPtr)

Closes an existing mutex handle. The mutex is destroyed if this is the last handle.

Declaration
public static void Close(IntPtr handle)
Parameters
Type Name Description
IntPtr handle

The mutex handle to be closed.

Exceptions
Type Condition
PlatformNotSupportedException

This method is called on a platform other than Windows.

Create(String, out Boolean)

Creates a new (or opens an existing) mutex.

Declaration
public static IntPtr Create(string name, out bool alreadyExists)
Parameters
Type Name Description
String name

The name to be used as a mutex identifier.

Boolean alreadyExists

true if an existing mutex was opened; false if a new one was created.

Returns
Type Description
IntPtr

The handle for the mutex. Can be used in Close(IntPtr). Will automatically be released once the process terminates.

Exceptions
Type Condition
Win32Exception

The native subsystem reported a problem.

PlatformNotSupportedException

This method is called on a platform other than Windows.

Probe(String)

Checks whether a specific mutex exists without opening a lasting handle.

Declaration
public static bool Probe(string name)
Parameters
Type Name Description
String name

The name to be used as a mutex identifier.

Returns
Type Description
Boolean

true if an existing mutex was found; false if none existed.

Exceptions
Type Condition
Win32Exception

The native subsystem reported a problem.

PlatformNotSupportedException

This method is called on a platform other than Windows.

In This Article
Back to top Copyright Bastian Eicher