public static int Main(string [] args) { TcpChannel chan = new TcpChannel(); ChannelServices.RegisterChannel(chan, true); Client c = new Client(); thread1 = new Thread(new ThreadStart(c.RunMe)); thread2 = new Thread(new ThreadStart(c.RunMe)); thread1.Start(); thread2.Start(); Console.Read(); return 0; }
}//Main() /// <summary> /// Creates instances of the Client object and invokes methods. /// If the user specified to use both HTTP and TCP via threads then /// creates threads and waits for them to terminate. /// /// Allows the user to execute again. This allows seeing the effects /// in the server when running either SingleCall or Singleton. /// </summary> private static void InvokeServer() { try { //Use threads to do this. //Each thread has its own channel registered so they don't conflict. if (m_ChanKind == ChannelKind.Both) { Client CliObj1 = new Client(ChannelKind.Http, m_ObjType, m_CallConv, m_InvKind, m_Host); Thread thread1 = new Thread(new ThreadStart(CliObj1.Run)); CliObj1.ThreadNumber = 1; Client CliObj2 = new Client(ChannelKind.TCP, m_ObjType, m_CallConv, m_InvKind, m_Host); Thread thread2 = new Thread(new ThreadStart(CliObj2.Run)); CliObj2.ThreadNumber = 2; thread1.Start(); thread2.Start(); //Block on the threads until they both terminate. thread1.Join(); thread2.Join(); }//if else //Not threaded. { Client CliObj = new Client(m_ChanKind, m_ObjType, m_CallConv, m_InvKind, m_Host); CliObj.Run(); }//else }//try catch (Exception e) { Console.WriteLine("Exception in InvokeServer: {0}", e.ToString()); return; }//catch Console.Write("\nRun again? "); string Reply = Console.ReadLine(); Console.WriteLine(); if (Reply.ToLower() == "y" || Reply.ToLower() == "yes") { InvokeServer(); }//if }//InvokeServer()