Logical
|
The LogicalThread type exposes the following members.
Name | Description | |
---|---|---|
LogicalThread | Creates a new instance of the LogicalThread class. |
Name | Description | |
---|---|---|
CurrentThread | Gets the logical thread that is currently executing. | |
HasAction | Gets a flag that indicates whether the logical thread has any unprocessed actions left in its queue. | |
PriorityLevels | Gets the number of levels of priority supported by this logical thread. |
Name | Description | |
---|---|---|
Clear | Clears all actions from the logical thread. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) | |
GetHashCode | Serves as the default hash function. (Inherited from Object) | |
GetType | Gets the Type of the current instance. (Inherited from Object) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) | |
Push(Action) | Pushes an action to the logical thread. | |
Push(Int32, Action) | Pushes an action to the logical thread. | |
SampleStatistics | Samples the statistics, providing current statistic values and resetting statistic counters. | |
ToString | Returns a string that represents the current object. (Inherited from Object) |
Name | Description | |
---|---|---|
UnhandledException | Handler for unhandled exceptions on the thread. |
Name | Description | |
---|---|---|
GetEnumValueOrDefault |
Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) | |
GetEnumValueOrDefaultT |
Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) | |
Join |
Creates an awaitable that ensures the continuation is running on the logical thread.
(Defined by LogicalThreadExtensions) | |
Join |
Creates an awaitable that ensures the continuation is running on the logical thread.
(Defined by LogicalThreadExtensions) | |
Yield |
Creates an awaitable that asynchronously yields
to a new action on the logical thread when awaited.
(Defined by LogicalThreadExtensions) | |
Yield |
Creates an awaitable that asynchronously yields
to a new action on the logical thread when awaited.
(Defined by LogicalThreadExtensions) |
This class provides a simple alternative to synchronization primitives such as wait handles and locks. Actions dispatched to a logical thread will be processed synchronously as though it was executed as consecutive method calls. All such actions can be dispatched from any thread in the system so method calls coming from multiple threads can be easily synchronized without locks, loops, wait handles, or timeouts.
Note that the LogicalThreadScheduler implements its own thread pool to execute tasks pushed to logical threads. Executing long-running processes or using synchronization primitives with high contention or long timeouts can hinder the logical thread scheduler's ability to schedule the actions of other logical threads. Like other thread pool implementations, you can mitigate this by increasing the maximum thread count of the logical thread scheduler, however it is recommended to avoid using synchronization primitives and instead synchronize those operations by running them as separate actions on the same logical thread.