2009 Dec 11

- by
Sean Lee

C# Thread

간단한 Thread 코드 C

public void ControlServerTest()
  {
    ControlServer controlServer = new ControlServerSync();
    ProxyServer proxyServer = ProxyServer.CreateProxyServer(ProxyServerConfig.PrivateAddressRangeConfigSingle);
    controlServer.ProxyServer = proxyServer;

    new Thread(() =>
    {
      Thread.Sleep(1000);
      Console.WriteLine("receive ACK");
      proxyServer.SignalMessageReceiveEvent("ACK");
      Thread.Sleep(3000);
      Console.WriteLine("receive INVITE");
      proxyServer.SignalMessageReceiveEvent("INVITE");
    })
    {
      Name = "Receive Thread"
    }.Start();

    string method = "INVITE";
    proxyServer.InitMessageReceiveEvent();
    Console.WriteLine("wait INVITE");
    bool received = proxyServer.WaitMessageReceiveEvent(method, new TimeSpan(0,0, 10));
    Console.WriteLine("wait: " + received);
    Thread.Sleep(3000);
  }