title: How to call a method on a running thread?
body: <p>On a console application, i am currently starting an array of threads.  The thread is passed an object and running a method in it.  I would like to know how to call a method on the object inside the individual running threads.</p>
  
  <p>Dispatcher doesn't work.  SynchronizationContext "Send" runs on the calling thread and "Post" uses a new thread.  I would like to be able to call the method and pass parameters on a running thread on the target thread it's running on and not the calling thread.</p>
  
  <p>Update 2: Sample code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data.SqlClient;
  using System.Linq;
  using System.Text;
  using System.Threading;
  using System.Threading.Tasks;
  
  namespace CallingFromAnotherThread
  {
      class Program
      {
          static void Main(string[] args)
          {
              var threadCount = 10;
              var threads = new Thread[threadCount];
              Console.WriteLine("Main on Thread " + Thread.CurrentThread.ManagedThreadId);
              for (int i = 0; i &lt; threadCount; i++)
              {
                  Dog d = new Dog();
                  threads[i] = new Thread(d.Run);
                  threads[i].Start();
              }
              Thread.Sleep(5000);
  
              //how can i call dog.Bark("woof");
              //on the individual dogs and make sure they run on the thread they were created on.
              //not on the calling thread and not on a new thread.
          }
  
      }
  
      class Dog
      {
          public void Run()
          {
              Console.WriteLine("Running on Thread " + Thread.CurrentThread.ManagedThreadId);
          }
  
          public void Bark(string text)
          {
              Console.WriteLine(text);
              Console.WriteLine("Barking on Thread " + Thread.CurrentThread.ManagedThreadId);
          }
      }
  }
  </code></pre>
  
  <p>Update 1:
  Using synchronizationContext.Send results to using the calling thread</p>
  
  <pre><code>Channel created
  Main thread  10
  SyncData Added for thread 11
  Consuming channel ran on thread 11   
  Calling AddConsumer on thread 10
  Consumer added consumercb78b. Executed on thread 10
  Calling AddConsumer on thread 10
  Consumer added consumer783c4. Executed on thread 10
  </code></pre>
  
  <p>Using synchronizationContext.Post results to using a different thread</p>
  
  <pre><code>Channel created
  Main thread  10
  SyncData Added for thread 11
  Consuming channel ran on thread 11   
  Calling AddConsumer on thread 12
  Consumer added consumercb78b. Executed on thread 6
  Calling AddConsumer on thread 10
  Consumer added consumer783c4. Executed on thread 7
  </code></pre>