Пример #1
0
        private void workerServer_DoWork(object sender, DoWorkEventArgs e)
        {
            ServerItem       item   = e.Argument as ServerItem;
            BackgroundWorker worker = sender as BackgroundWorker;

            if (item == null || worker == null)
            {
                return;
            }

            if (worker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            item.Info();
        }
Пример #2
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            workerServer.CancelAsync();
            this.buttonDelete.Enabled = false;

            if (gridListServers.SelectedIndex != -1)
            {
                int        index = gridListServers.SelectedIndex;
                ServerItem item  = this.serverItems[index];

                this.serverItems.RemoveAt(index);

                ListSoruce();

                this.userFile.Delete(item.GetAddress(), item.GetPort());
                this.userFile.Write();
            }

            this.gridListServers.SelectedIndex = -1;
        }