473,756 Members | 2,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BackgroundWorke rProcess 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 backgroundworke rprocess 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
backgroundworke rprocess 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 3569
RTFM.. ;-)

In your DoWork event handler, you'll have to use the
BackgroundWorke r.ReportProgres s 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 backgroundworke rprocess 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
backgroundworke rprocess 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
BackgroundWorke r.ReportProgres s 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
2767
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 Smalltalk I would fire of notification exceptions that a progress bar would catch, increment progress, and then allow to continue (or no
9
13619
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 want to have a nice progress bar in another form e.g ProgressForm to perform the search action. i tried to do it but the progress bar won't work and the GUI freezed. I knew how to do with the single threading but i don't know how to do it in...
7
5390
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. I have tried doing this and using a progress bar that counts up to 100 and then zeros down so that it should be constantly moving while the main or background windows finishes loading. The problem is that the "in progress window" doesn't display...
8
5199
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? thanks... Imports System Imports System.Drawing Imports System.Drawing.Drawing2D
2
2185
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 update , I dont use a form unless i have two. This , creates either one of two problems. When i'm downloading asynchonously , the main thread exits!
5
6934
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 sound. But my little app is a 'fake' app and is designed to look like another - hence this seeming crazy situation of needing to fake a progess bar. PROBLEM.
1
2722
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 servlet code: The local script regularly polls the servlet, which uses the session to check on the progress of the other program and reports back with an XML file. The local script then updates the progress bar as necessary. This works nicely until...
2
1171
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 seconds and then pops up a timeout message with an OK button that closes the form when pressed. Also, the user has an option of closing the form while the bar is being updated. Thus, this form needs to be threaded. The main form calls the progress...
10
2054
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 multiple labels and i'm using a text box for status updates. the labels change when a task completes. the text box report what task is running. so 1) when i call _ProgressChange i need that function to passed the label i
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.