473,388 Members | 1,399 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,388 software developers and data experts.

BackgroundWorker and 'freezing' application

Greetings,

I was much encouraged to see the new BackgroundWorker 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 BackgroundWorker1 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 RunWorkerCompleted 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 8713
Take a look at the basics here (the BackgroundWorker 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.microsoft.com> escribió en el
mensaje news:38**********************************@microsof t.com...
Greetings,

I was much encouraged to see the new BackgroundWorker 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 BackgroundWorker1 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 RunWorkerCompleted 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 BackgroundWorker class.

I was hoping to avoid doing a rewrite, using delegates, BeginInvoke etc,
since that is what the BackgroundWorker 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 BackgroundWorker 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.microsoft.com> escribió en el
mensaje news:38**********************************@microsof t.com...
Greetings,

I was much encouraged to see the new BackgroundWorker 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 BackgroundWorker1 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 RunWorkerCompleted 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
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...
1
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...
0
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...
5
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...
3
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...
8
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...
9
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...
4
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...
4
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...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.