Skip to main content

DeferredSynchronizeInvoke

A class in Root.Township, the global namespace.

An ISynchronizeInvoke that queues calls from other threads and runs them on the thread that created it when ProcessQueue is called.

Constructors​

MemberWhat it is
DeferredSynchronizeInvoke()Creates a DeferredSynchronizeInvoke with default values.

Fields​

2 private and internal fields
MemberWhat it is
private Queue<DeferredSynchronizeInvoke.UnityAsyncResult> fifoToExecuteQueued calls, locked while used.
private Thread mainThreadThe thread that created this object.

Properties​

MemberWhat it is
bool InvokeRequired { get; }True when called from a thread other than the creating one.

Methods​

MemberWhat it is
IAsyncResult BeginInvoke(Delegate method, object[] args)Queues the method to run on the main thread at the next ProcessQueue, and returns at once.
object EndInvoke(IAsyncResult result)Blocks until a queued call has run on the main thread, then returns its result.
object Invoke(Delegate method, object[] args)Runs the method now if this is the main thread; otherwise queues it and waits for it to run there.
void ProcessQueue()Runs all queued calls and stores their results. Throws if not called from the creating thread.