Progress bar while importing, best practice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Søren Reinke

    Progress bar while importing, best practice

    Hi there

    I am working on a program where the user should be able to import some CSV
    files.

    With my set of test data, it takes about 2 minutes to import, while it is
    importing the program sort of freezes.

    Therefore i would like to open a little window with a progress bar in it
    that shows how far the import has come.

    What is the best practice for doing this ?
    I have a class with the CSV import parser in it, with one method doing
    everything (of course it calls other methods as will).

    So should i let the form with the progress bar call the import class ?

    Another question regarding this import is, at the moment i fill all the data
    into 2 tables in a dataset, and store it in a JET database when the import
    is finish, would it be best to store it one record at a time ?

    Hope my questions makes sense :)

    --
    Søren Reinke
    www.Xray-Mag.com/ - Your free diving magazin on the net.
    Current issue Diving in North America, 99 pages.
    Download it in PDF


  • Maqsood Ahmed

    #2
    Re: Progress bar while importing, best practice

    Hello,
    First of all it should not freeze the interface. CSV importing should
    be done in a worker thread, you can use Invoke method to update the
    progress bar on the basis of amount of data you have processed. Now its
    upto you that you open a new window and display the progress bar or
    display it at the same form where you have started the process.

    HTH. Cheers.
    Maqsood Ahmed [MCP,C#]
    Kolachi Advanced Technologies


    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • Søren Reinke

      #3
      Re: Progress bar while importing, best practice

      Hello
      [color=blue]
      > First of all it should not freeze the interface. CSV importing should
      > be done in a worker thread, you can use Invoke method to update the
      > progress bar on the basis of amount of data you have processed. Now its
      > upto you that you open a new window and display the progress bar or
      > display it at the same form where you have started the process.[/color]

      I am quite new to .net programming, might you have a little example on how
      to do that in a workerthread ?

      Would you suggest the calling class opens a form window with the progressbar
      in it, then starts a workerthread who then updates the progress bar ?

      --
      Søren Reinke
      www.Xray-Mag.com/ - Your free diving magazin on the net.
      Current issue Diving in North America, 99 pages.
      Download it in PDF
      [color=blue]
      >
      > HTH. Cheers.
      > Maqsood Ahmed [MCP,C#]
      > Kolachi Advanced Technologies
      > http://www.kolachi.net
      >
      > *** Sent via Developersdex http://www.developersdex.com ***[/color]


      Comment

      • Michael McCarthy

        #4
        Re: Progress bar while importing, best practice

        As said, you need to move your import code (and any other code that puts
        a tax on the system) into another thread that runs asyncronously.

        One thing I'll mention is that as far as progress bars go, it has to
        report "some" progress... not necissarily thee progress... What I mean
        is that, for example, most of the time in async web calls you are only
        getting an indication that progress is being made, but not the exact
        ammount of progress because that isn't always known.


        Here's the text I put in a similar thread:

        You can either set up an IAsync, which I think is painful and a lot of
        work, or you can add a backgroundworke r control (2.0), and the
        workercompleted even will fire when its done... (you can do whatever you
        want in that time, including being idle)...

        one page with a few references to the background worker control is here:


        this one is also popular:
        There can be more than Notion and Miro. AFFiNE is a next-gen knowledge base that brings planning, sorting and creating all together.


        or this is a fairly good video on IAsync by Mike Taulty:



        Søren Reinke wrote:[color=blue]
        > Hello
        >
        >[color=green]
        >> First of all it should not freeze the interface. CSV importing should
        >>be done in a worker thread, you can use Invoke method to update the
        >>progress bar on the basis of amount of data you have processed. Now its
        >>upto you that you open a new window and display the progress bar or
        >>display it at the same form where you have started the process.[/color]
        >
        >
        > I am quite new to .net programming, might you have a little example on how
        > to do that in a workerthread ?
        >
        > Would you suggest the calling class opens a form window with the progressbar
        > in it, then starts a workerthread who then updates the progress bar ?
        >[/color]

        Comment

        • Søren Reinke

          #5
          Re: Progress bar while importing, best practice

          Thanks for the link's i'll look into it :)


          --
          Søren Reinke
          www.Xray-Mag.com/ - Your free diving magazin on the net.
          Current issue Diving in North America, 99 pages.
          Download it in PDF
          [color=blue]
          >
          > one page with a few references to the background worker control is here:
          > http://weblogs.asp.net/rosherove/arc...16/156948.aspx
          >
          > this one is also popular:
          > http://www.mikedub.net/mikeDubSample...owsForms20.htm
          >
          > or this is a fairly good video on IAsync by Mike Taulty:
          > http://www.microsoft.com/uk/asx/msdn...rvicecalls.asx
          >[/color]


          Comment

          • Søren Reinke

            #6
            Re: Progress bar while importing, best practice

            Thanks for the link's i'll look into it :)


            --
            Søren Reinke
            www.Xray-Mag.com/ - Your free diving magazin on the net.
            Current issue Diving in North America, 99 pages.
            Download it in PDF
            [color=blue]
            >
            > one page with a few references to the background worker control is here:
            > http://weblogs.asp.net/rosherove/arc...16/156948.aspx
            >
            > this one is also popular:
            > http://www.mikedub.net/mikeDubSample...owsForms20.htm
            >
            > or this is a fairly good video on IAsync by Mike Taulty:
            > http://www.microsoft.com/uk/asx/msdn...rvicecalls.asx
            >[/color]


            Comment

            Working...