Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:44:55+00:00 2026-06-01T08:44:55+00:00

i am use my Winform application to send buffer of packet to my network

  • 0

i am use my Winform application to send buffer of packet to my network card, my application show to progress via Progress Bar, if i choose to send all the buffer with out any delay between the packets my application stuck (become gray) and return to normal behaviour only after senging all the buffer (in case my buffer is very big, something like > 50,000 packets)
so how can i deal with such case ? maybee to change the backgroundworker who check all my class properties (number of packet send etc…) with event ?

    listBoxFiles.SetSelected(0, true);
    bgWoSingle = new BackgroundWorker();
    bgWoSingle.WorkerReportsProgress = true;
    bgWoSingle.ProgressChanged += new ProgressChangedEventHandler(bgW_ProgressChanged);
    bgWoSingle.DoWork += new DoWorkEventHandler(
    (s3, e3) =>
    {
        while (loopsCount < numberOfLoops && bContinuePlay && ifContinue)
        {
            for (int i = 0; (i < listBoxFiles.Items.Count) && bContinuePlay && ifContinue; i++)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    lbCurrentFileNum.Text = "(" + (i + 1) + "/" + listBoxFiles.Items.Count + "):";
                });

                string path = (string)listBoxFiles.Items[i];
                pcap = new Pcap(path, playSpeed, isSync);
                pcap._startTimer += new EventHandler(pcap_packetStartTimer);
                pcap._stopTimer += new EventHandler(pcap__packetStopTimer);
                pcap.evePacketProgress += new Pcap.dlgPacketProgress(
                    (progressCount) =>
                    {
                        pcap._fileSelectedIndex = i;
                        bgWoSingle.ReportProgress(progressCount, pcap);
                    });

                if (selectedAdapter != null)
                {
                    //play the file
                    bContinuePlay = pcap.playCapture(selectedAdapter._packetDevice);                     }
            }

            loopsCount++;
        }

    bgWoSingle.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
        (s3, e3) =>
        {

        }
        );

    bgWoSingle.RunWorkerAsync();

here i check the class properties (class name is pcap):

void bgW_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    //check the properties and update the UI
    labelPacketSent.Text = pcap._numberOfSendPackets.ToString("#,##0"); 
    progressBar1.Value = e.ProgressPercentage;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:44:56+00:00Added an answer on June 1, 2026 at 8:44 am

    You have to use BackGroundWorker for it. I am adding a small example for it.

    private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
    {
          backgroundWorker.ReportProgress(80, 15000);
    }
    
    private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
         var numberOfPackets = int.parse(e.UserState);
    
         MessageBox.Show("Percentage: " + e.ProgressPercentage );
         MessageBox.Show("Packets sent :" + numberOfPackets);  
    }
    

    The worker can send the percentage of completion or any other data you want through UserState.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use the log4net to log the winform application's event and error. Our customer
I use the following code to allocate a Console for a WinForm application. The
Can I use MapPoint in my c# Winform Application. I mean I couldn't find
I have a WinForm application which uses SqlServer CE 3.5 as database. I use
I am creating a winform application where I use Nhibernate. In my app I
I want to use Entity Framework(with Self Track Entities) in my winform application; but
i use a sound player in my winform application. Is there a way to
In a Winform application,I want to use a single backgroundworker (or may be one
I have made a winform application for use within the company I work for(
I am trying to use the libusb to a WinForm application. I used several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.