예제 #1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int[] speeds = { speed1, speed2, speed3 };
            System.ComponentModel.BackgroundWorker worker;
            worker = (System.ComponentModel.BackgroundWorker)sender;
            networkProtocol np = (networkProtocol)e.Argument;

            np.workState = working;
            np.serialPingServers(worker, e, speeds);
        }
예제 #2
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {   // Параллельный поток для отдельного хоста (ускорение прохода по списку хостов).
            int[] speeds = { speed1, speed2, speed3 };
            System.ComponentModel.BackgroundWorker worker;
            worker = (System.ComponentModel.BackgroundWorker)sender;
            var             myArgs = e.Argument as MyWorkerArgs;
            serverControl   serv   = myArgs.srv;
            networkProtocol np     = myArgs.netP;

            workState    = working;
            np.workState = working;
            np.parallelPingServers(worker, e, speeds, serv);
        }
예제 #3
0
        public string picON, picOFF;       // путь к картинкам

        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            networkProtocol np = new networkProtocol();

            np.serverList = servers;
            if (!backgroundWorker1.IsBusy)
            {
                backgroundWorker1.RunWorkerAsync(np);
                toolStripProgressBar1.Visible = true;
                toolStripStatusLabel2.Text    = "Waiting for ping";
                toolStripStatusLabel2.Visible = true;
            }
        }
예제 #4
0
        private void serialPinging()
        {
            cancel = false;
            networkProtocol np = new networkProtocol();

            np.serverList = servers;
            if (!backgroundWorker1.IsBusy)
            {
                backgroundWorker1.RunWorkerAsync(np);
                toolStripProgressBar1.Visible = true;
                toolStripStatusLabel2.Text    = "Waiting for serial ping";
                toolStripStatusLabel2.Visible = true;
            }
        }
예제 #5
0
        private void parallelPinging()
        {
            cancel = false;
            networkProtocol np = new networkProtocol();

            np.serverList = servers;
            foreach (serverControl server in servers)
            {
                threadList.Add(new BackgroundWorker()
                {
                    WorkerReportsProgress = true, WorkerSupportsCancellation = true
                });
                threadList.Last().DoWork             += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker2_DoWork);
                threadList.Last().ProgressChanged    += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker2_ProgressChanged);
                threadList.Last().RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker2_RunWorkerCompleted);
                threadList.Last().RunWorkerAsync(new MyWorkerArgs(server, np));
                toolStripProgressBar1.Visible = true;
                toolStripStatusLabel2.Text    = "Waiting for parallel ping";
                toolStripStatusLabel2.Visible = true;
                System.Threading.Thread.Sleep(speed1);
            }
        }
예제 #6
0
 public MyWorkerArgs(serverControl server, networkProtocol np)
 {
     srv  = server;
     netP = np;
 }
예제 #7
0
 public MyWorkerArgs(serverControl server, networkProtocol np)
 {
     srv = server;
     netP = np;
 }
예제 #8
0
 private void serialPinging()
 {
     cancel = false;
     networkProtocol np = new networkProtocol();
     np.serverList = servers;
     if (!backgroundWorker1.IsBusy)
     {
         backgroundWorker1.RunWorkerAsync(np);
         toolStripProgressBar1.Visible = true;
         toolStripStatusLabel2.Text = "Waiting for serial ping";
         toolStripStatusLabel2.Visible = true;
     }
 }
예제 #9
0
 private void parallelPinging()
 {
     cancel = false;
     networkProtocol np = new networkProtocol();
     np.serverList = servers;
     foreach (serverControl server in servers)
     {
         threadList.Add(new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true });
         threadList.Last().DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker2_DoWork);
         threadList.Last().ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker2_ProgressChanged);
         threadList.Last().RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker2_RunWorkerCompleted);
         threadList.Last().RunWorkerAsync(new MyWorkerArgs(server, np));
         toolStripProgressBar1.Visible = true;
         toolStripStatusLabel2.Text = "Waiting for parallel ping";
         toolStripStatusLabel2.Visible = true;
         System.Threading.Thread.Sleep(speed1);
     }
 }
예제 #10
0
 private void connectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     networkProtocol np = new networkProtocol();
     np.serverList = servers;
     if (!backgroundWorker1.IsBusy)
     {
         backgroundWorker1.RunWorkerAsync(np);
         toolStripProgressBar1.Visible = true;
         toolStripStatusLabel2.Text = "Waiting for ping";
         toolStripStatusLabel2.Visible = true;
     }
 }