Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 8th, 2008, 12:20 AM   #1
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 194
Rep Power: 1 BstrucT is on a distinguished road
Windows Forms: Timers / Progress Bar help needed.

Hi to all out there!

I have recently made somewhat a transition into the world of C# and have worked through quite a few tutorials by now and started playing with windows forms.

I wrote a little data capturing application that takes various user inputs and display them all on a text file to preview, from where the user can save the text file.

I would like insert a progress bar for when another form is opened, or when data is being saved, do I need to use a timer?

If so does anyone know of links that I can read up on the subject?

I've looked around but to no avail.
Thanks

>>BstrucT
__________________
Be kinder than necessary because everyone you meet is fighting some kind of battle.
BstrucT is offline   Reply With Quote
Old Feb 8th, 2008, 10:20 PM   #2
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Re: Windows Forms: Timers / Progress Bar help needed.

The progress bar will probably have very little time to display/be useful for opening forms/saving text files. Such operations are typically near instant except for large amounts of data.

Look in to the BackgroundWorker component. It is essentially a thread, nicely wrapped up to allow progress reporting, cancellation, etc. This means that your program will be in "two places" at once - multitasking within your program just as you can have multiple programs running at one time. The form will continue to be responsive while saving, etc occurs in the background. The progress bar can be updated as needed (note: limit number of progress updates to something reasonable). Threading introduces certain difficulties, but if you use BackgroundWorker as it is intended, most are avoided altogether.

BackgroundWorker is not suitable for opening a new form. This has to be done on the main thread (the only one allowed to touch windows forms-related stuff). However, creating a form takes an insignificant amount of time. What may take time is loading the data to be displayed. That's what you may need to put in the background.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Feb 11th, 2008, 2:55 AM   #3
BstrucT
Hobbyist Programmer
 
BstrucT's Avatar
 
Join Date: Dec 2007
Location: Durban, South-Africa
Posts: 194
Rep Power: 1 BstrucT is on a distinguished road
Re: Windows Forms: Timers / Progress Bar help needed.

Thanks man, have just printed off some docs on the background worker and will start checking it out.

I see now that the progress bar is dependant on data being handled by the backgound worker in a way, will revert if I encounter any problems.

Thanks for the advice.
__________________
Be kinder than necessary because everyone you meet is fighting some kind of battle.
BstrucT is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP Activation Loop... Ghost Coder's Corner Lounge 3 Jan 24th, 2008 3:28 PM
Typical Revisons from windows 2000 to windows xp ronaldr C++ 2 Nov 23rd, 2007 10:17 PM
looking for a good windows programming book cwl157 Coder's Corner Lounge 3 May 30th, 2007 6:51 AM
Windows Vista, well sort of coldDeath Coder's Corner Lounge 21 Sep 6th, 2005 1:00 PM
Net Group /ADD (on a windows box, non domain controller) Infinite Recursion Other Programming Languages 1 Apr 13th, 2005 2:27 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:48 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC