|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Where to do the Loading tasks for application ?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. 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 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 Well, how about :>> don't you just find a faster way to do that 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.
Show quote
Hide quote
On 5 Apr 2006 18:19:29 -0700, "Cerebrus" <zorg***@sify.com> wrote: Is the Xml File local?>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. 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 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.
Trying to "display" control characters in a text box
Unique Machine Identifier Have you upgraded to VS 2005? Getting the selected item from a listview Foreign Language Names Joining files closing a form for mobile application error line number Typed Dataset and Numeric Only Fields in VB.Net 2005 ? Suggest a vb.net online tutorial |
|||||||||||||||||||||||