private void AddFinishedService(FinishedService FS)
 {
     lock (Lock)
     {
         finishedServices.Add(FS);
     }
 }
        private void ThreadFunction()
        {
            ActiveThreads++;
            while (!UserStopped)
            {
                Service service = GetWork();
                if (service == null)
                {
                    break;
                }

                FinishedService FS = new FinishedService();
                FS.TestedService = service;
                FS.Succeeded     = Connect(service.IP, service.Port, service.Protocol);
                AddFinishedService(FS);
            }

            ActiveThreads--;
            while (ActiveThreads > 0)
            {
                Thread.Sleep(1000);
            }
            scanningActive = false;
        }
        private void ThreadFunction()
        {
            ActiveThreads++;
            while (!UserStopped)
            {
                Service service = GetWork();
                if (service == null)
                    break;

                FinishedService FS = new FinishedService();
                FS.TestedService = service;
                FS.Succeeded = Connect(service.IP, service.Port, service.Protocol);
                AddFinishedService(FS);
            }

            ActiveThreads--;
            while (ActiveThreads > 0)
                Thread.Sleep(1000);
            scanningActive = false;
        }
 private void AddFinishedService(FinishedService FS)
 {
     lock (Lock)
     {
         finishedServices.Add(FS);
     }
 }