private void SendCommandToComputer(object data)
        {
            ADComputer      computer        = null;
            DataForComputer dataForComputer = (DataForComputer)data;
            DataGridViewRow row             = dataForComputer.Row;

            String[] options = dataForComputer.Options;
            System.Threading.CountdownEvent countDown = dataForComputer.CountDown;

            try
            {
                Action startAction = () =>
                {
                    lock (dtGrvComputers)
                    {
                        if (!_closing && !_aborting)
                        {
                            row.Cells["Status"].Value = resMan.GetString("SendingCommand");
                            computer = (ADComputer)row.Cells["Computer"].Value;
                        }
                    }
                    Logger.Write("Will try to send InstallPendingUpdates on : " + computer.Name);
                };
                if (!_closing && !_aborting)
                {
                    this.Invoke(startAction);
                }

                ADComputer.InstallPendingUpdatesResult result = ADComputer.InstallPendingUpdatesResult.FailToSendCommand;
                if (!_closing && !_aborting)
                {
                    result = computer.InstallPendingUpdates(options, Username, Password);
                }

                Action endAction = () =>
                {
                    Logger.Write("Result for " + computer.Name + " is : " + result.ToString());

                    lock (dtGrvComputers)
                    {
                        if (!_closing && !_aborting)
                        {
                            row.Cells["Status"].Value = resMan.GetString(result.ToString());
                        }
                    }
                };
                if (!_closing && !_aborting)
                {
                    this.Invoke(endAction);
                }
            }
            catch (Exception) { }
            finally { countDown.Signal(); }
        }
        private void SendUpdateCommand()
        {
            Logger.EnteringMethod();
            string[] options = GetOptions();

            if (dtGrvComputers.Rows.Count > 0)
            {
                System.Threading.CountdownEvent countDown = new System.Threading.CountdownEvent(1);
                foreach (DataGridViewRow row in dtGrvComputers.Rows)
                {
                    if (_aborting || _closing)
                    {
                        break;
                    }
                    countDown.AddCount();
                    DataForComputer data = new DataForComputer();
                    data.Row       = row;
                    data.Options   = options;
                    data.CountDown = countDown;
                    System.Threading.ThreadPool.QueueUserWorkItem(SendCommandToComputer, data);
                }
                countDown.Signal();
                countDown.Wait();
            }
            Action finishAction = () =>
            {
                chkBxCancelIfRebootIsPending.Enabled         = true;
                chkBxIncludeUpdatesthatRequireReboot.Enabled = true;
                chkBxPersonalizeSearchString.Enabled         = true;
                txtBxPersonalizeSearchString.Enabled         = true;
                btnStartUpdating.Enabled = true;
                btnClose.Enabled         = true;
                _aborting = false;
            };

            if (!_closing)
            {
                this.Invoke(finishAction);
            }
        }