473,725 Members | 2,173 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 3564
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
2765
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
13617
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
2184
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
6931
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
2721
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
1169
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
2052
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
8888
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
8752
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
9257
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...
0
9113
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...
0
8097
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.