Table of Contents

Class MutexLock

Namespace
NanoByte.Common.Threading
Assembly
NanoByte.Common.dll

Provides a wrapper around Mutex that automatically acquires on creating and releases on Dispose().

[MustDisposeResource]
public sealed class MutexLock : IDisposable
Inheritance
object
MutexLock
Implements
Extension Methods

Examples

Instead of lock (_object) { code(); } for per-process locking use using (new MutexLock("name") { code(); } for inter-process locking.

Remarks

Constructors

MutexLock(string)

Acquires Mutex with name.

public MutexLock(string name)

Parameters

name string

Methods

Dispose()

Releases the Mutex.

public void Dispose()

Remarks

Must be called from the same thread that instantiated this object.