Table of Contents

Class AppMutex

Namespace
NanoByte.Common.Native
Assembly
NanoByte.Common.dll

Provides a cross-process object allowing easy detection of application instances (e.g., for use by installers and update tools). No-op on non-Windows platforms.

[MustDisposeResource]
public sealed class AppMutex
Inheritance
object
AppMutex
Extension Methods

Remarks

Use System.Threading.Mutex or MutexLock instead for synchronizing access to shared resources.

Methods

Create(string)

Creates or opens a mutex to signal that an application is running.

[MustDisposeResource]
public static AppMutex Create(string name)

Parameters

name string

The name to be used as a mutex identifier.

Returns

AppMutex

The handle for the mutex. Can be used to close it again. Will automatically be released once the process terminates.

Dispose()

Closes the mutex handle, allowing it to be released if no other instances are running.

public void Dispose()

Probe(string)

Checks whether a specific mutex exists (local or global) without opening a lasting handle.

public static bool Probe(string name)

Parameters

name string

The name to be used as a mutex identifier.

Returns

bool

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