Пример #1
0
        static void MultiThreadExec()
        {
            IAsyncResult result;
            LdtpdService ldtpService = new LdtpdService();

            try
            {
                while (true)
                {
                    try
                    {
                        GC.Collect();
                        if (ldtpService.debug)
                        {
                            Console.WriteLine("Waiting for clients");
                        }
                        result = ldtpService.listener.BeginGetContext(
                            new AsyncCallback(ldtpService.ListenerCallback),
                            ldtpService.listener);
                        result.AsyncWaitHandle.WaitOne();
                    }
                    catch (InvalidOperationException ex)
                    {
                        ldtpService.common.LogMessage(ex);
                    }
                    finally
                    {
                        result = null;
                    }
                }
            }
            catch (Exception ex)
            {
                ldtpService.common.LogMessage(ex);
            }
            finally
            {
                ldtpService.svc        = null;
                ldtpService.windowList = null;
                ldtpService.listener.Stop();
            }
        }
Пример #2
0
 static void MultiThreadExec()
 {
     IAsyncResult result;
     LdtpdService ldtpService = new LdtpdService();
     try
     {
         while (true)
         {
             try
             {
                 GC.Collect();
                 if (ldtpService.debug)
                     Console.WriteLine("Waiting for clients");
                 result = ldtpService.listener.BeginGetContext(
                     new AsyncCallback(ldtpService.ListenerCallback),
                     ldtpService.listener);
                 result.AsyncWaitHandle.WaitOne();
             }
             catch (InvalidOperationException ex)
             {
                 ldtpService.common.LogMessage(ex);
             }
             finally
             {
                 result = null;
             }
         }
     }
     catch (Exception ex)
     {
         ldtpService.common.LogMessage(ex);
     }
     finally
     {
         ldtpService.svc = null;
         ldtpService.windowList = null;
         ldtpService.listener.Stop();
     }
 }