title: How to raise cross thread event
body: <p>How can I raise the the event GeocodeAddressEventHandler from another thread?</p>
  
  <pre><code>    System.Threading.Thread MapThread;
      WinformMap map ;
  
      public delegate void GeocodeAddressEventHandler(object sender, EventArgs e);
      public event GeocodeAddressEventHandler GeocodeAddressEvent;
  
      //How to Raise this Event from another thread??
      public void GeocodeAddress_Raised(object sender, EventArgs e)
      {
          MapLib.GeocodeAddress("12798 1ST ST", "", "", "");
      }
  
      public bool LoadMap(string restorepoint)
      {
          ////////////////////////Engine Controls////////////////////////////////////////////////////////
          try
          {
              System.ServiceModel.OperationContext context = System.ServiceModel.OperationContext.Current;
  
              //This is to instantiate a winform from a Console (will convert to service shortly) 
              MapThread = new System.Threading.Thread(new System.Threading.ThreadStart(delegate
              {
                  using (System.ServiceModel.OperationContextScope scope = new System.ServiceModel.OperationContextScope(context))
                  {
  this.GeocodeAddressEvent += new GeocodeAddressEventHandler(GeocodeAddress_Raised);
                   }
              }));
              MapThread.SetApartmentState(System.Threading.ApartmentState.STA);
              MapThread.Start();
              MapThread.Join();
          }
          catch (Exception ex)
          {
              return false;
          }
  
          return true; 
      }
  </code></pre>
  
  <p>Actually it turned out that the thread was terminating after the scope of the delegate terminated.  This might be a dumb way to do it, but I put a while Queue.empty { sleep } in that scope so it never terminated, then I launched the LoadMap from yet another thread, so that it jam up my WCF service waiting for the neverending queue to terminate. </p>