473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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
5 7360
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jeff Wagner | last post by:
I am importing a file which contains a persons name (firstName, middleName, etc). If I define a function to do this, how can I use the variables outside of that function? Here is the code: ...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
6
by: Shawn Regan | last post by:
Hello, What is the best practice to show a window/form of some animation while processing is going on in the back ground. I want the user to see something while some processing is taking...
5
by: Miro | last post by:
I will try my best to ask this question correctly. I think in the end the code will make more sence of what I am trying to accomplish. I am just not sure of what to search for on the net. I...
1
by: Peter Hartlén | last post by:
Hi! Could someone please point me to a good tutorial or similar (what classes, small hint...) describing the best practice when it comes to importing database schema and data into a sql...
7
by: Marcus Kwok | last post by:
I am working on a program that reads and processes large text files (on the order of 32 MB, so not too huge), so I wanted to add a progress indicator so I can estimate when it will finish. I just...
7
by: kimiraikkonen | last post by:
Hello experts, I've been already working on a project and also asked and i've managed to create a basic Gmail mail sender, but i want to add a progressbar that shows "sending is in progress" but...
1
by: Sean Davis | last post by:
What is the "best practice" for importing an arbitrary module given that the name is stored in a variable? The context is a simple web application with URL dispatching to a module and function. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.