static void Main(string[] args) { ParameterizedThreadStart parameterizedThreadStart = new ParameterizedThreadStart(WriteSecond); Thread myThread = new Thread(parameterizedThreadStart); ThreadConfig threadConfig = new ThreadConfig(); myThread.Start(threadConfig); Console.ReadLine(); }
static void WriteSecond(object argument) { ThreadConfig config = (ThreadConfig)argument; for (int i = 0; i < config.count; i++) { Console.BackgroundColor = config.ConsoleBackgroundColor; Console.ForegroundColor = config.ConsoleForegroundColor; Console.WriteLine(config.msg); } }