API ReferenceSandbox
ThreadSafeclass
Provides utilities for working with threads, particularly for identifying and asserting code is running on the main thread.
object→ThreadSafe
Methods2
Showing 2 methods
public static void AssertIsMainThread(string memberName)
Throws an exception if not called from the main thread. Useful for enforcing thread safety on main-thread-only APIs.
| Parameter | Type | Description |
|---|---|---|
| memberName | string | Automatically filled with the calling method name |
Returns:
void—Exceptions
| Exception | Condition |
|---|---|
Exception | Thrown if not on the main thread |
public static void AssertIsNotMainThread()
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
| Exception | Condition |
|---|---|
Exception | Thrown if on the main thread |
No results match this filter.
Properties3
Showing 3 properties
public static int Sandbox.ThreadSafe.CurrentThreadId { get; set; }
Gets the current thread's managed thread ID.
Returns:
int—public static string Sandbox.ThreadSafe.CurrentThreadName { get; set; }
Gets the current thread's name, or null if unnamed.
Returns:
string—public static bool Sandbox.ThreadSafe.IsMainThread { get; set; }
Returns true if currently executing on the main thread.
Returns:
bool—No results match this filter.