Table of Contents

Class EtoFormDispatcher<T>

Namespace
NanoByte.Common.Threading
Assembly
NanoByte.Common.EtoForms.dll

Lazily creates a Eto.Forms.Form on the Eto.Forms UI thread and marshals interactions onto it.

public sealed class EtoFormDispatcher<T> : IDisposable where T : Form

Type Parameters

T

The type of the form to wrap.

Inheritance
object
EtoFormDispatcher<T>
Implements
Extension Methods

Remarks

This does not start a separate message loop. Eto.Forms runs a single Eto.Forms.Application on the main thread, so all interactions are marshaled onto that thread via Invoke(Action) and AsyncInvoke(Action). A running Eto.Forms.Application is therefore a precondition for using this class.

Constructors

EtoFormDispatcher(Func<T>)

Creates a new asynchronous form wrapper.

public EtoFormDispatcher(Func<T> init)

Parameters

init Func<T>

Callback that creates an instance of the form. Invoked on the UI thread on first access.

Methods

Close()

Closes the Eto.Forms.Form.

public void Close()

Remarks

Does nothing if the Eto.Forms.Form was not yet created or is already closed.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Post(Action<T>)

Executes an action on the UI thread, waiting for it to complete.

public void Post(Action<T> action)

Parameters

action Action<T>

The action to execute; gets passed the T instance.

Exceptions

OperationCanceledException

The form was closed.

Post<TResult>(Func<T, TResult>)

Executes a function on the UI thread, waiting for it to complete.

public TResult Post<TResult>(Func<T, TResult> action)

Parameters

action Func<T, TResult>

A delegate that is passed the T instance and returns a result.

Returns

TResult

The result returned by action.

Type Parameters

TResult

The type of the result returned by action.

Exceptions

OperationCanceledException

The form was closed.

Send(Action<T>)

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

public void Send(Action<T> action)

Parameters

action Action<T>

The action to execute; gets passed the T instance.

Exceptions

OperationCanceledException

The form was closed.

SendLow(Action<T>)

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

public void SendLow(Action<T> action)

Parameters

action Action<T>

The action to execute; gets passed the T instance.

Remarks

Does nothing if the Eto.Forms.Form was not yet created or is already closed.