running one process after another using multithreading and c#
<p>I use multithreading to process a list of data.
In this example below, for each element, how to make sure "SecondProcess" always runs after "FirstProcess" finishes? The order of elements in the queue being processed doesn't really matter.</p>

<pre><code>public class Processor
{
    public void Process()
    {
        IList&lt;int&gt; queue = QueueGenerator.GetRandomInt(50); //gets a list of 50 unique random integer

        foreach (int eachElement in queue)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(FirstProcess), eachElement);
        }
        Console.ReadLine();
    }

    private void FirstProcess(object toProcess)
    {
        int i = 0;
        int.TryParse(toProcess.ToString(), out i);

        string odd = "odd";
        string even = "even";

        string toDisplay = (i%2 == 0)
                               ? string.Format("First step: Processing {0} ({1} number)", i, even)
                               : string.Format("First step: Processing {0} ({1} number)", i, odd);

        Console.WriteLine(toDisplay);
    }

    private void SecondProcess(object toProcess)
    {
        int i = 0;
        int.TryParse(toProcess.ToString(), out i);
        Console.WriteLine("Second step: Processing -&gt; {0}", i);
    }
}
</code></pre>

<p>any idea please?</p>

<p>Thanks</p>