Wrox Programmer Forums
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2008, 12:01 PM
Authorized User
 
Join Date: Oct 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ricespn
Default Text File and Progress bar

Hi Guys,

I wrote an application in VB.NET 2003 to read a text file line by line and generate an XML file with some values from the text file. The text file is 1 MB and the XML file after creation can be 3.7MB.

While the application is running it looks like is frozen, so i added a progress bar but the progress bar don't show any progress only after is done.

How can I refresh the progress bar to show the user that the program is doing something?



=======================
Strange and crazy, but everything is possible
__________________
=======================
Strange and crazy, but everything is possible
 
Old October 2nd, 2008, 09:03 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The problem is likely that your process is busy doing the actual processing and no or few cycles are being dedicated to the UI. You need to create a new thread to handle the file I/O processing. .NET has a component called BackgroundWorker that you can put into the application. This component handles some of the details of dealing with progress updates from long running processes. You give the worker something to do and from that process you can call the "ReportProgress" method to report the progress of your process.

The reason that this is important is that you can't make UI update calls on a secondary thread. Only the thread that created the UI elements (forms, controls, etc) can make those calls. The background worker component handles the cross thread messaging for you which greatly simplifies simple background processing tasks.

-Peter
compiledthoughts.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me to show progress bar during file upload subhasps8 ASP.NET 2.0 Professional 5 June 27th, 2007 06:39 PM
progress bar treasacrowe Classic ASP Basics 11 February 11th, 2005 10:47 AM
progress bar while getting file from FTP Dhodie Pro VB 6 4 October 28th, 2004 10:15 PM
upload file, progress bar ivris Servlets 0 July 21st, 2004 06:52 AM
upload file, progress bar ivris J2EE 0 July 21st, 2004 06:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.