Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's nothing stopping you from having synchronous commands and then having only some of the execution code run asynchronously without having to separate services.</p> <p>You mentioned that you have separated your "triggers". I assume that means they run as separate methods? That being the case, you can easily run them in the background and let your main WCF thread return, without having to separate services. (The code below is NOT assuming event sourcing.)</p> <pre><code>public class MyCommandHandler { public string Do(MyCommand1 command) { var myCrmObject = ... ; // load some object string message = myCrmObject.CriticalWork(command); // synchronous ThreadPool.QueueUserWorkItem(x =&gt; myCrmObject.OtherWork(command)); // async // async alternative 1 //Action&lt;MyCommand1&gt; action = myCrmObject.OtherWork; // make into action delegate //action.BeginInvoke(null, command); // start action async, no callback // async alternative 1a - custom delegate instead of Action. same BeginInvoke call // async alternative 2 - Background Worker // async alternative 3 - new System.Threading.Thread(...).Start(command); return message; // will be here before OtherWork finishes (or maybe even starts) } } </code></pre> <p>If you were using an event stream and event handlers to perform database writes and integrate with other systems, then this could be structured a bit better. You could have your individual event handlers worry about whether it should execute synchronously or not.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload