473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

BackgroundWorkerProcess and GUI updates (progress windows)

Hi,

I'm writing a little application that scans a large number of media
files for processing.

The main application currently uses a backgroundworkerprocess to
perform the scan. Each media file has meta data extracted and is added
to one of a range of lists (pseudo-queues) for later processing. This
is all fine. But, I want to provide more feedback to the end user as to
progress as the process takes a considerable time.

To do so I have implemented a new modal dialog which outputs counts on
queues, and the current location in the filesystem that the scanning
has reached.

However, I have problems with this.

Firstly, I tried creating the new progress window in the main form
class, that then failed as when I tried to update the labels and
controls on the progress window I could not as the window was created
in another thread.

Then, I tried to create the progress window within the method that the
backgroundworkerprocess thread runs. This did not allow me to create a
modal dialog as I could not pass "this" into the constructor, because
the variable was not created in the same process.

I don't really want to move the logic into the progress window, because
I need to deal with the queues when populated.

This is just all seeming to be too much of a mess. Updating a progress
window is such a COMMON thing that applications do all the time. There
/must/ be a tried and tested pattern for doing so, I can't beleive that
..NET doesn't have a nice simple way to do this.

However, I've failed to find it so far. I'm new to .NET and winforms.
I've done some limited GUI programming in Delphi and a tiny bit in VB6,
I'm primarily an enterprise web application developer. i.e. I can code
well in the web paradigm, but my thick client gui stuff is almost
completely non-extant.

Any pointers to RTFM greatly accepted.

(Oh, .NET 2.0 in C# Express 2005)

Cheers,

Mike

Sep 18 '06 #1
2 3549
RTFM.. ;-)

In your DoWork event handler, you'll have to use the
BackgroundWorker.ReportProgress method. DoWork should be adding to
the queues, and you UI should be handling the ProgressChanged event to
update the labels / progress bar.

HTH
Michael Jervis wrote:
Hi,

I'm writing a little application that scans a large number of media
files for processing.

The main application currently uses a backgroundworkerprocess to
perform the scan. Each media file has meta data extracted and is added
to one of a range of lists (pseudo-queues) for later processing. This
is all fine. But, I want to provide more feedback to the end user as to
progress as the process takes a considerable time.

To do so I have implemented a new modal dialog which outputs counts on
queues, and the current location in the filesystem that the scanning
has reached.

However, I have problems with this.

Firstly, I tried creating the new progress window in the main form
class, that then failed as when I tried to update the labels and
controls on the progress window I could not as the window was created
in another thread.

Then, I tried to create the progress window within the method that the
backgroundworkerprocess thread runs. This did not allow me to create a
modal dialog as I could not pass "this" into the constructor, because
the variable was not created in the same process.

I don't really want to move the logic into the progress window, because
I need to deal with the queues when populated.

This is just all seeming to be too much of a mess. Updating a progress
window is such a COMMON thing that applications do all the time. There
/must/ be a tried and tested pattern for doing so, I can't beleive that
.NET doesn't have a nice simple way to do this.

However, I've failed to find it so far. I'm new to .NET and winforms.
I've done some limited GUI programming in Delphi and a tiny bit in VB6,
I'm primarily an enterprise web application developer. i.e. I can code
well in the web paradigm, but my thick client gui stuff is almost
completely non-extant.

Any pointers to RTFM greatly accepted.

(Oh, .NET 2.0 in C# Express 2005)

Cheers,

Mike
Sep 18 '06 #2

Andy wrote:
RTFM.. ;-)

In your DoWork event handler, you'll have to use the
BackgroundWorker.ReportProgress method. DoWork should be adding to
the queues, and you UI should be handling the ProgressChanged event to
update the labels / progress bar.
I can't beleive I missed that...

Thanks a lot.

Sep 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bob | last post by:
Hello, I want to show progress to the user while some method is running so I thought I'd use a progress bar. But I don't see how I can do this without writing GUI code in the model? In...
9
by: Popoxinhxan | last post by:
Dear experts, i want to develop an client application that consume the google search web service. In my MainForm i have a method to retrieve all the search result e.g. GetGoogleResults(). Now i...
7
by: Pepi Tonas | last post by:
I have a form that takes some time to load because it has to populate some Data. I was trying to display a form on top of it with an activity bar so that user can see that something's going on. ...
8
by: Brian Henry | last post by:
I created a smooth progress bar with this code.. but if you update the values in a row quickly of it and watch it on screen it flickers... how would i change this to reduce the flickering?...
2
by: giddy | last post by:
hi , I'm in a slight dilemma. I have an updater program that checks for pending updates and downloads them if the users chooses to. Since i dont need a windows form to check if there is an...
5
by: CCLeasing | last post by:
For an application I'm creating I want to create a 'fake' progress bar. By fake I mean a progress bar that looks like it's doing something but actually isn't. I know philosophically this isn't...
1
by: Arancaytar | last post by:
I am working on a servlet that takes fairly long to process, and I would like to keep the user updated on the progress with a status bar. I have already finished the necessary javascript and...
2
by: mikelis | last post by:
I have a main form that does a lengthy database query. Before I fire off the query, I need to pop up another form that contains a progress bar and a Close button. The progress bar updates for 30...
10
by: =?Utf-8?B?YXVsZGg=?= | last post by:
am having a hard time wrapping my head around "backgroundworker" class and updates to the window form that calls it. i have some questions about how to update windows form controls. i have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.