title: What is the difference between SynchronizationContext.Send and SynchronizationContext.Post?
body: <p>Thanks to Jeremy Miller's good work in <a href="http://msdn.microsoft.com/en-us/magazine/ee309512.aspx" rel="noreferrer">Functional Programming For Everyday .NET Development</a>, I have a working command executor that does everything I want it to (do heavy lifting on the thread pool, send results or errors back to the synchronization context, and even post progress back to the synchronization context), but I can't explain why it uses <a href="http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.send.aspx" rel="noreferrer">SynchronizationContext.Send</a> from the thread-pool and <a href="http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.post.aspx" rel="noreferrer">Synchronization.Post</a> from the <code>Func</code> passed into the method that does the heavy lifting. I have read the documentation, several times, but I just can't get a gut sense for what the difference is. What am I supposed to get from the fact that one is called <code>Send</code> and one is called <code>Post</code>? I sense the magic is in the fact <code>Send</code> "starts a <strong>synchronous</strong> request" and <code>Post</code> "starts an <strong>asynchronous</strong> request", but both requests come from the thread pool and need to be sent/posted back to the UI thread.</p>
  
  <p>Can someone explain the difference, even if it is just a mnemonic device that lets me know when to choose one over the other?</p>
  
  <p>In case it matters, this is my <strong>test code</strong> where I use <code>Post</code> to send progress back to the UI:</p>
  
  <pre><code>private Action _ExecuteCommand
                  (SynchronizationContext context
                   , Action&lt;int, int&gt; progress
                   , Action&lt;int, int&gt; after)
  {
      int count = 3;
      int accumulatedValue = 0;
      int threadId = Thread.CurrentThread.ManagedThreadId;
      for (int i = 0; i &lt; count; i++)
      {
          Thread.Sleep(1000);
          context.Post(delegate { progress(i + 1, threadId); });
          accumulatedValue += i;
      }
  
      return () =&gt; after(threadId, accumulatedValue);
  }
  </code></pre>
  
  <p>That <code>_ExecuteCommand</code> method is passed in as the <code>command</code> parameter below, mostly from the original article, that uses <code>Send</code> to send completion and error message back to the UI:</p>
  
  <pre><code>public void Execute(Func&lt;Action&gt; command, Action&lt;Exception&gt; error)
  {
      ThreadPool.QueueUserWorkItem(o =&gt;
       {
           try
           {
               Action continuation = command();
               _Context.Send(s =&gt; continuation());
           }
           catch (Exception e)
           {
               _Context.Send(s =&gt; error(e));
           }
       });
  }
  </code></pre>