/// <summary> /// Starts an asynchronous scanning of the given adresses /// </summary> /// <param name="AdressesToCheck"></param> /// <remarks></remarks> public virtual void BeginScan(List <System.Net.IPEndPoint> AdressesToCheck) { if (AdressesToCheck == null) { throw new ArgumentException("AdressesToCheck can not be NULL"); } if (AdressesToCheck.Count == 0) { throw new ArgumentException("AdressesToCheck can not be empty"); } if (isRunning) { throw new InvalidOperationException("Can only start when not running"); } else { //Create Worker Threads int ThreadToCreate = Math.Min(AdressesToCheck.Count, _ThreadCount); for (int i = 1; i <= ThreadToCreate; i++) { _Threads.Add(new ScannerWorker(this)); } //Start Operation _CheckIndex = -1; _AdressesToCheck = AdressesToCheck; _DiscoveredAdresses = new List <IPEndPoint>(); foreach (ScannerWorker Thread in _Threads) { Thread.BeginWork(); lock (_ThreadCountLock) { _RunningThreads += 1; if (RunningThreadCountChanged != null) { RunningThreadCountChanged(this, EventArgs.Empty); } } } } }