コード例 #1
0
        public void Start()
        {
            if (ProxyMgr == null || ProxyMgr.Count < 1)
            {
                return;
            }

            Threads++;
            MyProxy proxy = ProxyMgr.RecommendProxy(); //Recommended proxy is from List<> not HashSet<>

            while (proxy != null && !TerminateThreads)
            {
                while (PauseThreads)
                {
                    Thread.Sleep(333);
                    if (TerminateThreads)
                    {
                        PauseThreads = false;
                        continue; //confirm to which loop this applies to nub
                    }
                }

                proxy.Test();
                Scanned++;
                if (proxy.isAlive)
                {
                    Alive++;
                    if (proxy.Type == ProxyType.Http)
                    {
                        Https++;
                    }
                    else
                    {
                        Socks++;
                    }

                    if (proxy.AnonLevel == Anonymity.Transparent)
                    {
                        Trans++;
                    }
                    else if (proxy.AnonLevel == Anonymity.High)
                    {
                        High++;
                    }
                    else if (proxy.AnonLevel == Anonymity.Elite)
                    {
                        Elite++;
                    }

                    ProxyMgr.AddToAlive(proxy); //has lock in-case of IndexOutOfRange Exc
                    Program.UI.AddToListView(proxy);
                }
                else
                {
                    Dead++;
                    ProxyMgr.Dead.Add(proxy);
                }

                //Program.UI.UpdateScannerUI();
                proxy = ProxyMgr.RecommendProxy(); //cycle proxies
            }//stop scan

            Threads--;
            Console.WriteLine(string.Format("***Thread '{0}' terminated, reason is '{1}'... '{2}' Threads left running...",
                                            Thread.CurrentThread.Name, TerminateThreads?"STOP PRESSED":"FINISHED", Threads.ToString())); //Debug

            //Program.UI.UpdateScannerUI(); //Sends Message that scanning has finished!!!
            //Reset();
        }