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 7248367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:07:43+00:00 2026-05-28T22:07:43+00:00

I am trying to get a ProgressBar with the progress of a dataset being

  • 0

I am trying to get a ProgressBar with the progress of a dataset being converted to Excel using the BackgroundWorker. The problem is that the work is being done in a different class than the ProgressBar and I am having difficulty calling worker.ReportProgress(...) from within my loop. I am sorry if this is a easy thing but I am new to C# and have been trying this the whole day and just can’t seem to get it right. Your help would be HIGHLY appreciated.

namespace CLT
{
    public partial class GenBulkReceipts : UserControl
    {
        private void btnOpen_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                OpenFile();
            }

            Cursor.Current = Cursors.Default;
        }
        private void OpenFile()

        {
            if (dsEx1.Tables[0].Rows.Count > 0)
            {
                  backgroundWorker1.RunWorkerAsync(dsEx1);
            }
        }

        public void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            DataSet ImportDataSet = e.Argument as DataSet;
            AccountsToBeImported = new BLLService().Get_AccountsToBeReceipted(ImportDataSet);
        }

        public void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.progressBar1.Value = e.ProgressPercentage;
        }

        // ...
    }
}

namespace BLL
{
    class GenBulkReceiptsBLL
    {
        public DataSet Get_AccountsToBeReceipted(DataSet dsImport)
        {
            DataSet dsReturn = AccountsDAL.QGenReceiptAccounts(0,0,"");//Kry Skoon DataSet wat ge-populate moet word

            CLT.GenBulkReceipts pb = new CLT.GenBulkReceipts();
            int TotalRows = dsImport.Tables[0].Rows.Count;
            //pb.LoadProgressBar(TotalRows);
            int calc = 1;
            int ProgressPercentage;

            foreach (DataRow dr in dsImport.Tables[0].Rows)
            {
               ProgressPercentage = (calc / TotalRows) * 100;

                //This is the problem as I need to let my Progressbar progress here but I am not sure how
                //pb.worker.ReportProgress(ProgressPercentage);
            }

            return dsReturn;
        }

        // ...
    }
}
  • 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-05-28T22:07:44+00:00Added an answer on May 28, 2026 at 10:07 pm

    Your class GenBulkReceiptsBLL needs some reference to the BackgroundWorker instance. You can achieve this in a variety of ways. One such suggestion would be to pass the reference to the class when instantiating it.

    For example, since GenBulkReceipts is the class that instantiates GenBulkReceiptsBLL, then in the constructor for GenBulkReceiptsBLL, you could pass the instance of the BackgroundWorker that is currently being used in GenBulkReceipts. This would allow for you to call ReportProcess(...) directly. Alternately, you could pass the reference directly into the Get_AccountsToBeReceipted(...) method.

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

Sidebar

Related Questions

I'm trying get LocalConnection to work between two swf's placed within two different IFRAMES.
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
I'm trying to get a file upload progress bar working in a rails 3
I have been trying to get the following code working. It's a progress bar
I am trying to get simple Progress bar when I clicking on item list
I have been trying to get a progressbar set to marquee to keep moving

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.