![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
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
__________________
>BstrucT |
|
|
|
|
|
#2 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 730
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
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.
__________________
>BstrucT |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |