473,770 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference BackgroundWorke r / Threads

Can anybody tell me, whats the main difference between a BackgroundWorke r and
a Thread? What are the advantages/disadvanteges? When use a BackgroundWorke r,
when a Thread?
Apr 29 '06 #1
4 2556
DHarry <DH****@discuss ions.microsoft. com> wrote:
Can anybody tell me, whats the main difference between a BackgroundWorke r and
a Thread? What are the advantages/disadvanteges? When use a BackgroundWorke r,
when a Thread?


BackgroundWorke r operates in a different thread already. It just
provides a convenient way of reporting progress with all the
marshalling back to the UI thread being done for you.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 29 '06 #2
The nice thing about a BackgroundWorke r component is that it handles all the
marshalling for you, with a consistent and fairly simple object model. In a
Windows Forms app, this can be a real time-saver for the developer.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DHarry <DH****@discuss ions.microsoft. com> wrote:
Can anybody tell me, whats the main difference between a BackgroundWorke r
and
a Thread? What are the advantages/disadvanteges? When use a
BackgroundWorke r,
when a Thread?


BackgroundWorke r operates in a different thread already. It just
provides a convenient way of reporting progress with all the
marshalling back to the UI thread being done for you.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 30 '06 #3
I see... is it right that a BackgroundWorke r is a special kind of Thread with
additional methods?
Apr 30 '06 #4
Not exactly. A BackgroundWorke r is a component, which encapsulates the
functionality to marshall between an asynchronous Thread and the Windows
Form STA Thread.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"DHarry" <DH****@discuss ions.microsoft. com> wrote in message
news:C4******** *************** ***********@mic rosoft.com...
I see... is it right that a BackgroundWorke r is a special kind of Thread
with
additional methods?

Apr 30 '06 #5

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

Similar topics

2
8749
by: Sebastian Crewe | last post by:
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...
5
14134
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). This all works great when I'm NOT using Threading (BackgroundWorker), however, as soon as I...
9
5024
by: =?Utf-8?B?VE9NX1Bhc2FkZW5h?= | last post by:
Hello, In my ASP.Net app I'm launching a BackgroundWorker thread in my Page_Load function. In that thread I'm attempting to connect to a SQL server using this connection string "Initial Catalog=MyDB;Data Source=MyServer;Integrated Security=True;". When I use the same connection string in my main thread of execution it works fine. However when I use that connection string in the newly created thread I get this exception: "Login...
8
16581
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
18034
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 backgroundworker and then use the Show method and hide method as necessary? Anyone know of
3
1687
by: Piotrekk | last post by:
I have a question. One day i have been working with threads. Thread had 'while' loop that checked locked value telling the thread when application was closing ( in Dispose method i set locked object's value to 'true'). If i didn't have the locked object the thread was present in taskmanager even when application has been already gone. My question is:
3
1839
by: Coaster | last post by:
I want to create a "thread manager" class to manage an array of backgroundworkers. I'd like this thread manager class to live in a class library and I wasn't sure if it was possible to make the thread manager a subclass of the backgroundworker so that I could start it up and still do other things on the client. Essentially a thread that spins off new threads. Am I going to hit any limitations here? thank you
2
11869
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have introduced a component to my solution that is throwing an exception about needing to be run in single threaded apartment mode. This component is created in an async call by a BackgroundWorker object, which seems to be on a MTA thread. Is there a way for me to get the BackgroundWorker thread to run in STA mode, or do I have to remove the BackgroundWorker and hand spin my own async call?
1
10393
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, Is it possible "kill" the thread of Backgroundworker ? In my Dowork event, I have NOT While for do e.Cancel = true, only have a call to external COM. If I want cancel, calling CancelAsync, not cancels the call to COM. How I can do it , please ? Any suggestions will be very appreciated.
0
9617
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
10099
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
10037
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
9904
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
5354
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.