Threading not concurrent? What have I missed?

May 5 2010 1:10 PM

I'm pretty new to threading so apologies if I've not understood correctly. I'm trying to create a thread which will run a background Merge Replication sync on a windows mobile device. I need this to run in the background, doing the sync every few minutes but not holding up the main program in the process.

so, here's the code I've created just to test the principle:

  static void ThreadMethod()
Debug.WriteLine("Thread a " + Thread.CurrentThread.ManagedThreadId + " has control");
for(int i=0;i<10000;i++){

private void runTest(object sender, EventArgs e)
new Thread(new ThreadStart(ThreadMethod)).Start();
Debug.WriteLine("Thread b " + Thread.CurrentThread.ManagedThreadId + " has control");
for (int i = 0; i < 10000; i++)


I was hoping, that as both the code within 'runtest' and 'threadmethod' are running under seperate threads, I'd see a mixture of 'x' and 'y' in the debug console, indicating that they are both running simultaneously.

however I get this:

 Threadb 1856968798 has control
Threada -305810110 has control

This seems to be as though the threads aren't running concurrently.

Am I missing something?