Method Post
- Namespace
- SodaFlow.Bindable.ObjectModel
- Assembly
- SodaFlow.Core.Bindable.ObjectModel.dll
Post(Action)
Puts action in the queue for the binding thread. An
implementation MUST keep the first-in first-out sequence. It MUST NOT run
the action immediately while a transaction is open.
void Post(Action action)
Parameters
actionActionThe action to run.
Remarks
An implementation MUST NOT wait for the action to complete. SodaFlow calls this method in a transaction, and a transaction holds a lock for the full process while it runs. An implementation that gives the action to the binding thread and then waits causes a deadlock. The binding thread comes into this library through setters that open transactions of their own. Thus, it can already wait for the lock that the caller of this method holds. Put the action in the queue and return. Do not send it and wait.
An implementation on a message loop gets this behavior at no cost, because the post of a dispatcher is asynchronous. A scheduler that you write yourself, or one on a primitive that sends and waits, must be careful.
An action can throw, and some actions throw by design. A writable value posts the throw of a write that failed, because a binding engine discards a throw from a setter. See IWritableBindableValue<T>. Let that throw out of the action, as a dispatcher does. A scheduler that catches it and continues hides the defect again.