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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:59:22+00:00 2026-05-14T23:59:22+00:00

In my app, i have an import option, to read info from a .csv

  • 0

In my app, i have an import option, to read info from a .csv or .txt file and write it to a database. To test, i”m just using 200-300 lines of data. At the beginning of the method, i calculate number of objects/lines to be read. Every time an object is written to the database, i want to update my progressbar. This is how i do it :

private void Update(string path)
    {
        double lines = 0;
        using (StreamReader reader = new StreamReader(path))
            while ((reader.ReadLine()) != null)
                lines++;
        if (lines != 0)
        {
            double progress = 0;
            string lijn;
            double value = 0;
            List<User> users = new List<User>();
            using (StreamReader reader = new StreamReader(path))
                while ((line = reader.ReadLine()) != null)
                {
                    progress++;
                    value = (progress / lines) * 100.0;
                    updateProgressBar(value);
                    try
                    {
                        User user = ProcessLine(lijn);
                    }
                    catch (ArgumentOutOfRangeException)
                    { continue; }
                    catch (Exception)
                    { continue; }
                }
            return;
        }
        else
        {
           //non relevant code
        }
    }

To update my progressbar, i’m checking if i can change the ui of the progressbar like this :

delegate void updateProgressbarCallback(double value);

private void updateProgressBar(double value)
    {
        if (pgbImportExport.Dispatcher.CheckAccess() == false)
        {
            updateProgressbarCallback uCallBack = new updateProgressbarCallback(updateProgressBar);
            pgbImportExport.Dispatcher.Invoke(uCallBack, value);
        }
        else
        {
            Console.WriteLine(value);
            pgbImportExport.Value = value;
        }
    }

When i!m looking at the output, the values are calculated correctly, but the progressbar is only showing changes after the method has been called completely, so when the job is done. That’s too late to show feedback to the user.

Can anyone help me solve this.

EDIT :
I’m also trying to show some text in labels to tell te user what is being done, and those aren’t udpated till after the method is complete.

Thanks in advance.

  • 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-14T23:59:23+00:00Added an answer on May 14, 2026 at 11:59 pm

    This would be a good place to use a BackgroundWorker (here’s a link to MSDN’s description of it with an example).

    You can register an event handler for the ProgressChanged event (which you would raise periodically while performing the work of reading the lines).

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

Sidebar

Related Questions

Let's say I have the following code in Google App Engine: from urllib import
I have to import some XML data into my app. Now I open a
In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class
I have a C++ app in VS2005 and import a VB DLL. IntelliSense shows
I have a very simple dialog defined as: import android.app.AlertDialog; import android.content.Context; import android.view.LayoutInflater;
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
I have the following code: <fx:Script> <![CDATA[ import shared.GlobalsManager; import app.Globals; protected var globals:Globals=GlobalsManager.getGlobals();
I have a script that imports a models.py from an app, but it will
i have the following script i am using to scrap data from my uni
EDIT: Using simpler code. I have a blackberry app that until recently (I upgraded

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.