NanoByte.Common
Public Member Functions | List of all members
NanoByte.Common.AsyncFormWrapper< T > Class Template Reference

Lazily starts a separate thread with a message loop for a Form. More...

Inheritance diagram for NanoByte.Common.AsyncFormWrapper< T >:

Public Member Functions

 AsyncFormWrapper ([NotNull] Func< T > init)
 Creates a new asynchronous form wrapper. More...
 
void Post ([NotNull, InstantHandle] Action< T > action)
 Starts the message loop if it is not running yet and executes an action on its thread waiting for it to complete. More...
 
TResult Post< TResult > ([NotNull, InstantHandle] Func< T, TResult > action)
 Starts the message loop if it is not running yet and executes an action on its thread waiting for it to complete. More...
 
void Send ([NotNull] Action< T > action)
 Starts the message loop if it is not running yet and executes an action on its thread without waiting for it to complete. More...
 
void SendLow ([NotNull] Action< T > action)
 Executes an action on the message loop thread without waiting for it to complete. More...
 
void Close ()
 Closes the Form and stops the message loop. More...
 
void Dispose ()
 

Detailed Description

Lazily starts a separate thread with a message loop for a Form.

Template Parameters
TThe type of the form to wrap.
Type Constraints
T :Form 

Constructor & Destructor Documentation

◆ AsyncFormWrapper()

NanoByte.Common.AsyncFormWrapper< T >.AsyncFormWrapper ( [NotNull] Func< T >  init)
inline

Creates a new asynchronous form wrapper.

Parameters
initCallback that creates an instance of the form for the message loop.

Member Function Documentation

◆ Close()

void NanoByte.Common.AsyncFormWrapper< T >.Close ( )
inline

Closes the Form and stops the message loop.

Does nothing if the Form was not yet created.

◆ Post()

void NanoByte.Common.AsyncFormWrapper< T >.Post ( [NotNull, InstantHandle] Action< T >  action)
inline

Starts the message loop if it is not running yet and executes an action on its thread waiting for it to complete.

Parameters
actionThe action to execute; gets passed the T instance.
Exceptions
OperationCanceledExceptionThe form was closed.

◆ Post< TResult >()

TResult NanoByte.Common.AsyncFormWrapper< T >.Post< TResult > ( [NotNull, InstantHandle] Func< T, TResult >  action)
inline

Starts the message loop if it is not running yet and executes an action on its thread waiting for it to complete.

Template Parameters
TResultThe type of the result returned by action .
Parameters
actionA delegate that is passed the Form instance and returns a result.
Returns
The result returned by action .
Exceptions
OperationCanceledExceptionThe form was closed.

◆ Send()

void NanoByte.Common.AsyncFormWrapper< T >.Send ( [NotNull] Action< T >  action)
inline

Starts the message loop if it is not running yet and executes an action on its thread without waiting for it to complete.

Parameters
actionThe action to execute; gets passed the T instance.
Exceptions
OperationCanceledExceptionThe form was closed.

◆ SendLow()

void NanoByte.Common.AsyncFormWrapper< T >.SendLow ( [NotNull] Action< T >  action)
inline

Executes an action on the message loop thread without waiting for it to complete.

Does nothing if the Form was not yet created.

Parameters
actionThe action to execute; gets passed the T instance.
Exceptions
OperationCanceledExceptionThe form was closed.

The documentation for this class was generated from the following file: