ThreadSafeclass

Provides utilities for working with threads, particularly for identifying and asserting code is running on the main thread.

objectThreadSafe
Namespace
Sandbox
Assembly
Sandbox.System
Declaration
public static abstract sealed class Sandbox.ThreadSafe

Methods2

Showing 2 methods

public static void AssertIsMainThread(string memberName)PUBLICSTATIC

Throws an exception if not called from the main thread. Useful for enforcing thread safety on main-thread-only APIs.

ParameterTypeDescription
memberNamestringAutomatically filled with the calling method name
Returns:void

Exceptions

ExceptionCondition
ExceptionThrown if not on the main thread

public static void AssertIsNotMainThread()PUBLICSTATIC

Throws an exception if called from the main thread. Useful for enforcing that blocking operations don't run on the main thread.

Returns:void

Exceptions

ExceptionCondition
ExceptionThrown if on the main thread

Properties3

Showing 3 properties

public static int Sandbox.ThreadSafe.CurrentThreadId { get; set; }PUBLICSTATICGETSET

Gets the current thread's managed thread ID.

Returns:int

public static string Sandbox.ThreadSafe.CurrentThreadName { get; set; }PUBLICSTATICGETSET

Gets the current thread's name, or null if unnamed.

Returns:string

public static bool Sandbox.ThreadSafe.IsMainThread { get; set; }PUBLICSTATICGETSET

Returns true if currently executing on the main thread.

Returns:bool

On this page