By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Where to do the Loading tasks for application ?

P: n/a
Hi all,

I have an Windows application in which the startup form is called
"MainForm". Now when this form loads, I need to do some intensive tasks
like loading and parsing an XML file, that takes about 10-12 secs.

Initially I was doing it through Multi-threading, by calling the
intensive function (refer to as "LongTask()"), in a separate thread, in
the Load Event of the form. But the pitfall was that the user could
click the MenuItem that requires that function to have completed...

I have since added a "Loading" form with a progressbar as the startup
form, so that MainForm is shown only after all the Loading is done.

Now I am confused about where to add the task intensive function?
Should I transfer all it's code to the "Loading" form ? Or should I
make it a Public function in MainForm and call it from the "Loading"
form ? Or should I use a Shared Sub Main ?

An added complication is that I have to keep track of the progress of
the "LongTask" to show it in a progress bar.

I hope I am able to communicate the problem effectively.

Regards,

Cerebrus.

Apr 3 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Anyone ??

Apr 4 '06 #2

P: n/a
uh do it on the FORM_LOAD event lol

wish i coudl be more help

ps - wtf are you doing to ANY xml file that takes 10-12 seconds? why
don't you just find a faster way to do that

Apr 5 '06 #3

P: n/a
Hi,
wish i coudl be more help
No problem, I solved the issue.
wtf are you doing to ANY xml file that takes 10-12 seconds? why
don't you just find a faster way to do that


Well, how about :
1. Loading a 2 MB Xml File, that contains Books and Authors etc, into
an XPathDocument.
2. Selecting all distinct Authors, using an XPath expression.
3. Sorting this list.
4. For each author, traversing the entire Xml file, counting the no. of
books by this Author.
5. Adding this information to an ArrayList.

Can you think of a better way to do this ?

Regards,

Cerebrus.

Apr 6 '06 #4

P: n/a
On 5 Apr 2006 18:19:29 -0700, "Cerebrus" <zo*****@sify.com> wrote:
Hi,
wish i coudl be more help
No problem, I solved the issue.
wtf are you doing to ANY xml file that takes 10-12 seconds? why
don't you just find a faster way to do that


Well, how about :
1. Loading a 2 MB Xml File, that contains Books and Authors etc, into
an XPathDocument.
2. Selecting all distinct Authors, using an XPath expression.
3. Sorting this list.
4. For each author, traversing the entire Xml file, counting the no. of
books by this Author.
5. Adding this information to an ArrayList.

Can you think of a better way to do this ?

Regards,

Cerebrus.


Is the Xml File local?

I had a similar situation using a local xml file. I converted it to
an access db which is about 1/2 the xml file size. The preformance
with the db is 10 times faster than was with the xml file.

Gene
Apr 6 '06 #5

P: n/a
Hi Gene,

Thanks for your response.

Yes, the XML file is local. I know this could be done much faster using
a database, but the requirement in this case was to do it with an XML
file.

Oh well...

I think I have optimized it as much as possible, and the whole process
is now completed in 9 seconds. This is on my 433 MHz home PC, so I
think it might be good to go !

BTW, I found that I could gain 2.5 seconds by doing my stuff in the Sub
New() of the form, rather than the Form_Load event. I don't know what
the logic behind this could be, though.

Regards,

Cerebrus.

Apr 6 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.