Passing data to thread

Hello,
This might not be 100% Fez related but it will probably save me from asking the question in the future. When you have a thread you can only pass in one parameter so I passed in a object array. Lets say the array has data of the textbox, how can I do the following example with threading


public void GetIpInfo(string url, WebBrowser b)
        {
            StringBuilder sr = new StringBuilder();
            sr.Append(url);
            b.Navigate(sr.ToString());
        }
public void GetIpInfo(object array)
        {
            object[] data = array as object[];
            //the webrswer control to use is in the object array, how can I do it as shown in the first example
        }

You don’t need to pass variables to the thread function. Make the function part of a dedicated class, and you’ll have access to all the class members.

See my implementation of the abstract ascii line processor on codeshare: http://www.tinyclr.com/codeshare/entry/457

Rather than pass an object array, you can pass an instance of a class. For example (This is not tested, I just typed it up here so consider it pseudo code)


class MyThreadData
{
  public string Url {get; set;}
  public WebBrowser Browser {get; set;}
}

// Create the MyThreadData instance and populate it
MyThreadData theData = new MyThreadData(){Url="...", Browser = theBrowser};

// Create the thread
Thread myThread = new Thread(new ThreadProc(GetIpInfo));

// Start the thread passing the instance of the MyThreadData
myThread.Start(theData);

public void GetIpInfo(object state)
{
  MyThreadData data = (MyThreadData)state;
  
  // use data here...
}