467,075 Members | 1,089 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

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
Nov 17 '05 #1
  • viewed: 6961
Share:
5 Replies
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
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2
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.
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

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

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

Nov 17 '05 #3
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 backgroundworker 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:
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
Søren Reinke wrote:
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.

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 ?

Nov 17 '05 #4
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

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

Nov 17 '05 #5
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

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

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Jeff Wagner | last post: by
7 posts views Thread by Timothy Shih | last post: by
6 posts views Thread by Shawn Regan | last post: by
1 post views Thread by Peter Hartlén | last post: by
7 posts views Thread by Marcus Kwok | last post: by
1 post views Thread by Sean Davis | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.