public void ExecuteWindowsService()
    {
        var ws           = new WindowsService();
        var _eventHandle = new MyEventWaitHandler(false, EventResetMode.AutoReset, "WindowsApplicationMode");

        ws.Execute(_eventHandle);
        _eventHandle.Set();
    }
 public void Execute(MyEventWaitHandler _eventHandle)
 {
     Thread[] threads = new Thread[10];
     for (int i = 0; i < threads.Length; i++)
     {
         threads[i] = new Thread(Method);
         threads[i].Start();
         string name = _eventHandle.WaitNew();
         if (name == "WindowsApplicationMode")
         {
             //Execute case for first process
         }
         else if (name == "WebApplicationMode")
         {
             //Execute case for second process
         }
     }
 }