473,569 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BackgroundWorke r and 'freezing' application

Greetings,

I was much encouraged to see the new BackgroundWorke r class in .NET v2. On
the face of it, much easier to use than the various delegates and events of
yore, though I imagine the same base classes are being invoked.

Anyway, I have given it a try with a VB.NET application that generates
charts. Since there are some 3,000 charts to do, I wanted to put the chart
generation on a separate thread. Works fine inasmuch as the charts are made.
The problem is that the form UI is frozen after the job completes.
Actually, I think it freezes at some point during the background job running
but I haven't been able to determine if it is always after a fixed amount of
time.

For the first few minutes of background thread operation, I can move the
form around, minimize it etc. I repeat this exercise from time to time; most
often, the form is still responsive while othertimes it freezes. I am
testing this on a dual CPU HP DC7100, XP Pro, SP2.

I have treble-checked that nothing in the background thread touches the
form. I use a separate SQL connection from that used for populating UI
controls; I have taken the BackgroundWorke r1 object off the form design
surface and declared it manually (WithEvents); I have commented out all
ReportProgress calls (saw something on these perhaps being too frequent).

At the end of the job, I pop up a message box to say all done. This is
within the RunWorkerComple ted event. My understanding is that once this
event fires, then the background thread is finished and control is
automatically handed back to the UI thread. Is this correct?

Any ideas as to why the form freezes gratefully received. Are there any
tricks I can employ to determine at which point things are going wrong?

Thanks and regards

Sebastian Crewe
Mar 23 '06 #1
2 8730
Take a look at the basics here (the BackgroundWorke r class is a helper class
added to .NET 2.0):

Resources about asynchronous operations
http://www.mztools.com/resources_net...nousOperations

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Sebastian Crewe" <Se************ @discussions.mi crosoft.com> escribió en el
mensaje news:38******** *************** ***********@mic rosoft.com...
Greetings,

I was much encouraged to see the new BackgroundWorke r class in .NET v2.
On
the face of it, much easier to use than the various delegates and events
of
yore, though I imagine the same base classes are being invoked.

Anyway, I have given it a try with a VB.NET application that generates
charts. Since there are some 3,000 charts to do, I wanted to put the
chart
generation on a separate thread. Works fine inasmuch as the charts are
made.
The problem is that the form UI is frozen after the job completes.
Actually, I think it freezes at some point during the background job
running
but I haven't been able to determine if it is always after a fixed amount
of
time.

For the first few minutes of background thread operation, I can move the
form around, minimize it etc. I repeat this exercise from time to time;
most
often, the form is still responsive while othertimes it freezes. I am
testing this on a dual CPU HP DC7100, XP Pro, SP2.

I have treble-checked that nothing in the background thread touches the
form. I use a separate SQL connection from that used for populating UI
controls; I have taken the BackgroundWorke r1 object off the form design
surface and declared it manually (WithEvents); I have commented out all
ReportProgress calls (saw something on these perhaps being too frequent).

At the end of the job, I pop up a message box to say all done. This is
within the RunWorkerComple ted event. My understanding is that once this
event fires, then the background thread is finished and control is
automatically handed back to the UI thread. Is this correct?

Any ideas as to why the form freezes gratefully received. Are there any
tricks I can employ to determine at which point things are going wrong?

Thanks and regards

Sebastian Crewe

Mar 23 '06 #2
Thank you for the quick reply. I have been through these and similar
documentation. Most of the content is based on the underlying way of using a
background thread, not with using the BackgroundWorke r class.

I was hoping to avoid doing a rewrite, using delegates, BeginInvoke etc,
since that is what the BackgroundWorke r class is supposed to help with. The
problem remains of the user UI appearing to freeze; certainly it is
unresponsive, eg to being moved around. Meanwhile, Task Manager shows 0% CPU
for my application.

My background thread works fine if the job to complete takes 5 minutes or
less. I am not aware of a defualt timeout with background threads, but
perhaps I need to give wake up calls to the user UI once in a while? Any
guidelines for this? Is the fact that the PC has multi-processors something
I should be dealing with explicitly?

Thanks and regards

Sebastian

"Carlos J. Quintero [VB MVP]" wrote:
Take a look at the basics here (the BackgroundWorke r class is a helper class
added to .NET 2.0):

Resources about asynchronous operations
http://www.mztools.com/resources_net...nousOperations

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Sebastian Crewe" <Se************ @discussions.mi crosoft.com> escribió en el
mensaje news:38******** *************** ***********@mic rosoft.com...
Greetings,

I was much encouraged to see the new BackgroundWorke r class in .NET v2.
On
the face of it, much easier to use than the various delegates and events
of
yore, though I imagine the same base classes are being invoked.

Anyway, I have given it a try with a VB.NET application that generates
charts. Since there are some 3,000 charts to do, I wanted to put the
chart
generation on a separate thread. Works fine inasmuch as the charts are
made.
The problem is that the form UI is frozen after the job completes.
Actually, I think it freezes at some point during the background job
running
but I haven't been able to determine if it is always after a fixed amount
of
time.

For the first few minutes of background thread operation, I can move the
form around, minimize it etc. I repeat this exercise from time to time;
most
often, the form is still responsive while othertimes it freezes. I am
testing this on a dual CPU HP DC7100, XP Pro, SP2.

I have treble-checked that nothing in the background thread touches the
form. I use a separate SQL connection from that used for populating UI
controls; I have taken the BackgroundWorke r1 object off the form design
surface and declared it manually (WithEvents); I have commented out all
ReportProgress calls (saw something on these perhaps being too frequent).

At the end of the job, I pop up a message box to say all done. This is
within the RunWorkerComple ted event. My understanding is that once this
event fires, then the background thread is finished and control is
automatically handed back to the UI thread. Is this correct?

Any ideas as to why the form freezes gratefully received. Are there any
tricks I can employ to determine at which point things are going wrong?

Thanks and regards

Sebastian Crewe


Mar 24 '06 #3

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

Similar topics

2
9260
by: dm1608 | last post by:
Hi -- I have a C# application that basically has a button that executes a SQL Reader to loop thru a rather large resul set. Thru each interation of the reader object, I check to see if a file exists on the server. If it does, I update a textbox (multiline) with the missing file, update a status bar label, and a progressbar. Since this...
1
5341
by: Jakanapes | last post by:
Is it possible to suspend the background worker without cancelling it or letting it finish and restarting? My application runs in a loop and I'd like to have a pause button, but I'm having trouble getting it to work. I tried to create a loop based on a variable that gets set to false when pause is pressed so the worker will finish...
0
1074
by: Nicolas Zenou | last post by:
Hey everyone, I am new to .NET Framework programing and I have an important question. In fact, I need to launch many thread in my application. I assume to use backgroundWorker which are really easy to use. The plateform where the application will run is a Bi processor. I wanted to know if its possible to assign each of my backgroundWorker...
5
14115
by: Rob R. Ainscough | last post by:
I'm using a BackgroundWorker to perform a file download from an ftp site. Per good code design practices where I separate my UI code from my core logic code (in this case my Download file method in my FileIO class) I've established Public Event in my core logic classes along with RaiseEvents (that will updated a progress bar on the UI side). ...
3
3174
by: John Wright | last post by:
I have a background worker thread that scans the network listing computers that are connected. I have a delegate that I call that invokes a procdure that loads a dataset with computer names and then attaches it to a dropdown. When I run it, my UI freezes until it completes. Any thoughts on how to do this without freezing the UI? John ...
8
16548
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I have an application with several BackgroundWorker threads. I hoped I'd be able to just type backgroundworker1.Name = "bw1"; but I don't see a name property. Any thoughts on how to name a backgroundworker thread? Thanks, Randy
9
18007
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form will almost always lead to the user opening a certain child window that's fairly resource intensive to load. Is it possible to load this form in a...
4
2565
by: Sin Jeong-hun | last post by:
This is what I've always been wondered. Suppose I've created a class named Agent, and the Agent does some lengthy job. Of course I don't want to block the main window, so the Agent does the job in a separate thread. If the job is progressed it fires an event, and the main window handled the event by changing the value of a progress bar. The...
4
6381
by: =?Utf-8?B?U3ZlbiBXLg==?= | last post by:
Hi Newsgroup, I am developing a C# Windows Forms application that launches processes within a background worker.. The processes seem to have a memory limit of about 278mb. Some proccesses that get to that amount of used memory seem to hang ;-( Is there a memory limit that can be adjusted ?? The physical machine has 3
0
7609
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...
0
7921
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. ...
0
8118
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...
1
7666
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...
0
5217
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...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
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
1
1208
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.