title: Why is SynchronizationContext.Current null?
body: <p>Error: <code>Object reference not set to an instance of an object.</code></p>
  
  <p>The algorithm below works.
  I tried it, then I removed the <code>Winform</code> project to another directory and <code>SynchronizationContext.Current</code> is <code>null</code>.
  Why?</p>
  
  <pre><code>SynchronizationContext uiCtx = SynchronizationContext.Current;  
  
  private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  {
      int[] makeSelfMoves = new int[4];
  
      lock (replay)
      {
          // count should be more than 2
          foreach (KeyValuePair&lt;int, int[]&gt; item in replay)
          {              
              makeSelfMoves = replay[item.Key];
              codeFile.ExecuteAll(makeSelfMoves[0],
                makeSelfMoves[1], makeSelfMoves[2], makeSelfMoves[3]);
  
              // i get the error here. uictx is null
              uiCtx.Post(o =&gt;
              {
                  PrintPieces(codeFile.PieceState());
              }, null);                               
  
              System.Threading.Thread.Sleep(1000);
          }
      }
  }
  </code></pre>