Beispiel #1
0
 private void cmdStart_Click(object sender, EventArgs e)
 {
     cmdStart.Enabled = false;
     cmdStart.Text    = "B O M B I N G . . .";
     TargetURL        = txtURL.Text;
     iTimeout         = Convert.ToInt32(txtTimeout.Text);
     bChars           = radChars.Checked;
     iCCount          = Convert.ToInt32(txtCharCount.Text);
     Clients          = new WebReq[Convert.ToInt32(txtThreads.Text)];
     for (int a = 0; a < Clients.Length; a++)
     {
         Clients[a] = new WebReq();
         //Clients[a].SetTimeout(iTimeout);
     }
     iDownloaded = -(Clients.Length);
     StartTick   = new long[Clients.Length];
     tThreadState.Start(); tDownload.Start();
 }
Beispiel #2
0
        private void tThreadState_Tick(object sender, EventArgs e)
        {
            if (bintDownload)
            {
                return;
            }
            if (bintDisplay)
            {
                return;
            }
            bintDisplay = true;
            long cTick        = Tick();
            int  iThreads     = 0;
            int  iIdle        = 0;
            int  iConnecting  = 0;
            int  iRequesting  = 0;
            int  iDownloading = 0;

            for (int a = 0; a <= Clients.GetUpperBound(0); a++)
            {
                iThreads++;
                if (Clients[a].State == WebReq.ReqState.Ready ||
                    Clients[a].State == WebReq.ReqState.Completed)
                {
                    iIdle++;
                }
                if (Clients[a].State == WebReq.ReqState.Connecting)
                {
                    iConnecting++;
                }
                if (Clients[a].State == WebReq.ReqState.Requesting)
                {
                    iRequesting++;
                }
                if (Clients[a].State == WebReq.ReqState.Downloading)
                {
                    iDownloading++;
                }

                if (Clients[a].State == WebReq.ReqState.Failed ||
                    cTick > StartTick[a] + iTimeout)
                {
                    iDownloaded--;
                    if (Clients[a].State == WebReq.ReqState.Downloading)
                    {
                        iRequested++;
                    }
                    if (Clients[a].State != WebReq.ReqState.Downloading)
                    {
                        iFailed++;
                    }
                    //Clients[a] = null;
                    //Application.DoEvents();
                    Clients[a] = new WebReq();
                    //Clients[a].SetTimeout(iTimeout);
                    //Application.DoEvents();
                    //MessageBox.Show(
                    //    Clients[a].isReady + "\r\n" +
                    //    Clients[a].State);
                }
            }
            lbTotalThreads.Text = "" + iThreads;
            lbIdle.Text         = "" + iIdle;
            lbConnecting.Text   = "" + iConnecting;
            lbRequesting.Text   = "" + iRequesting;
            lbDownloading.Text  = "" + iDownloading;
            lbDownloaded.Text   = "" + iDownloaded;
            lbRequested.Text    = "" + iRequested;
            lbFailed.Text       = "" + iFailed;
            bintDisplay         = false;
        }