Click or drag to resize

ForegroundThreadWithDispatcher Class

A dedicated thread hosting an active dispatcher. The thread will be created as foreground thread, so this object must be explicitly disposed before the application can shut down.
Inheritance Hierarchy
SystemObject
  TomsToolbox.WpfThreadWithDispatcher
    TomsToolbox.WpfForegroundThreadWithDispatcher

Namespace: TomsToolbox.Wpf
Assembly: TomsToolbox.Wpf (in TomsToolbox.Wpf.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public sealed class ForegroundThreadWithDispatcher : ThreadWithDispatcher, 
	IDisposable

The ForegroundThreadWithDispatcher type exposes the following members.

Constructors
 NameDescription
Public methodForegroundThreadWithDispatcher(String, ApartmentState) Initializes a new instance of the ForegroundThreadWithDispatcher class with normal thread priority.
Public methodForegroundThreadWithDispatcher(String, ApartmentState, ThreadPriority) Initializes a new instance of the ForegroundThreadWithDispatcher class.
Top
Properties
 NameDescription
Public propertyDispatcher Gets the dispatcher of the thread.
(Inherited from ThreadWithDispatcher)
Public propertyShutdownPriority Gets or sets the shutdown priority passed to BeginInvokeShutdown(DispatcherPriority) when the object is disposed. The default is Normal
Public propertyTaskScheduler Gets the task scheduler associated with the Dispatcher
(Inherited from ThreadWithDispatcher)
Top
Methods
 NameDescription
Public methodAbortObsolete.
Aborts this instance.
(Inherited from ThreadWithDispatcher)
Public methodBeginInvoke(Action) Invokes the specified method asynchronously in the dispatcher thread.
(Inherited from ThreadWithDispatcher)
Public methodBeginInvoke(DispatcherPriority, Action) Invokes the specified method asynchronously in the dispatcher thread.
(Inherited from ThreadWithDispatcher)
Public methodBeginShutdown Initiates shutdown of the Dispatcher asynchronously.
(Inherited from ThreadWithDispatcher)
Public methodCheckAccess Determines whether the calling thread is the thread associated with this Dispatcher.
(Inherited from ThreadWithDispatcher)
Public methodDispose Shut down the dispatcher and wait for the thread to terminate.
Protected methodFinalize Finalizes an instance of the ForegroundThreadWithDispatcher class.
(Overrides ObjectFinalize)
Public methodInvoke(Action) Invokes the specified method in the dispatcher thread.
(Inherited from ThreadWithDispatcher)
Public methodInvokeT(FuncT) Invokes the specified method in the dispatcher thread.
(Inherited from ThreadWithDispatcher)
Public methodJoin Blocks the calling thread until the Dispatcher terminates.
(Inherited from ThreadWithDispatcher)
Public methodJoin(TimeSpan) Blocks the calling thread until the Dispatcher terminates.
(Inherited from ThreadWithDispatcher)
Public methodVerifyAccess Determines whether the calling thread has access to this Dispatcher.
(Inherited from ThreadWithDispatcher)
Top
Events
 NameDescription
Public eventTerminated Occurs when the dispatcher is terminated.
(Inherited from ThreadWithDispatcher)
Top
Extension Methods
 NameDescription
Public Extension MethodCode exampleReportNotDisposedObject Handle reporting of a not disposed object.

Using this pattern is a good practice to avoid code where disposable objects get never disposed.

Calling this method will raise the NotDisposedObject event if any event handler is attached; otherwise it will throw an InvalidOperationException if a debugger is attached. If the application does not run in a debugger and no event handler is attached, calling this method does nothing.
(Defined by Disposable)

Public Extension MethodSafeCastT Performs a cast from object to T, avoiding possible null violations if T is a value type.
(Defined by ObjectExtensions)
Top
Remarks
Use this thread to dispatch or serialize background operations, or to host COM objects that don't have a free threaded marshaller.
See Also