Beispiel #1
0
        public void Start()
        {
            IsRunning    = true;
            TotalSSH     = ListSSH.Length;
            TotalDown    = 0;
            TotalFresh   = 0;
            CurrentIndex = 0;
            ListFresh    = new StringBuilder();
            ListDown     = new StringBuilder();

            if (STP != null && STP.IsShuttingdown == false)
            {
                STP.Shutdown(true, 1000);
            }
            STP = new SmartThreadPool(TimeoutSeconds * 10 * 1000, TotalThreads, TotalThreads);

            for (int i = 0; i < TotalThreads; i++)
            {
                SshChecker sc = new SshChecker();
                sc.LineIndex      = CurrentIndex;
                sc.row            = ListSSH[CurrentIndex];
                sc.TimeoutSeconds = TimeoutSeconds;
                sc.DefaultPort    = DefaultPort;
                sc.passControl    = new SshChecker.PassControl(CheckFreshCallbank);
                //new Thread(new ThreadStart(sc.CheckFresh)).Start();
                STP.QueueWorkItem(sc.CheckFresh);
                CurrentIndex++;
                if (CurrentIndex == TotalSSH)
                {
                    break;
                }
            }

            new Thread(new ThreadStart(TimerCheckCompleted)).Start();
        }
Beispiel #2
0
        private void TimerCheckCompleted()
        {
            while (IsRunning)
            {
                Thread.Sleep(2000);

                if (CurrentIndex >= TotalSSH)
                {
                    STP.Shutdown(true, TimeoutSeconds * 3 * 1000);
                    if (STP.IsShuttingdown)
                    {
                        Message   = "Check Fresh Completed.";
                        IsRunning = false;
                        break;
                    }
                }

                if (CurrentIndex < TotalSSH)
                {
                    for (int i = STP.InUseThreads; i < TotalThreads; i++)
                    {
                        SshChecker sc = new SshChecker();
                        sc.LineIndex      = CurrentIndex;
                        sc.row            = ListSSH[CurrentIndex];
                        sc.TimeoutSeconds = TimeoutSeconds;
                        sc.DefaultPort    = DefaultPort;
                        sc.passControl    = new SshChecker.PassControl(CheckFreshCallbank);

                        //new Thread(new ThreadStart(sc.CheckFresh)).Start();
                        STP.QueueWorkItem(sc.CheckFresh);

                        CurrentIndex++;
                        if (CurrentIndex == TotalSSH)
                        {
                            break;
                        }
                    }
                }
            }
        }