C# thread with multiple parameters

Posted by Lucas B on Stack Overflow See other posts from Stack Overflow or by Lucas B
Published on 2009-05-06T18:29:07Z Indexed on 2010/04/10 4:13 UTC
Read the original article Hit count: 398

Does anyone know how to pass multiple parameters into a Thread.Start routine?

I thought of extending the class, but the C# Thread class is sealed.

Here is what I think the code would look like:

...
    Thread standardTCPServerThread = new Thread(startSocketServerAsThread);

    standardServerThread.Start( orchestrator, initializeMemberBalance, arg, 60000);
...
}

static void startSocketServerAsThread(ServiceOrchestrator orchestrator, List<int> memberBalances, string arg, int port)
{
  startSocketServer(orchestrator, memberBalances, arg, port);
}

Thank you in advance.

BTW, I start a number of threads with different orchestrators, balances and ports. Please consider thread safety also.

© Stack Overflow or respective owner

Related posts about c#

Related posts about multithreading