private void Query( ) { if (null == QueryDataCb) { return; } Clear( ); OnActionStart( ); var computerNames = GetComputerNamesFromString(txtComputers.Text); _dsThreadCount = computerNames.Count; foreach (var currentName in computerNames) { var computerName = currentName; new Thread(() => { try { if (WmiHelpers.IsAlive(computerName)) { QueryDataCb(computerName, _ds); } else { var value = new T { ComputerName = computerName, ConnectionStatus = ConnectionStatuses.ConnectionError }; InvokeIfNeeded(() => _ds.Add(value)); } } finally { if (0 >= Interlocked.Decrement(ref _dsThreadCount)) { OnActionEndInvoke( ); } } }).Start( ); } }