Hello,
I need to create a background thread and two (or more) options are available
to me:
1. BackgroundWorke r
2. Asynch delegate method and BeginInvoke
What are the differences between them in performance, complexity etc.
Thanks,
EitanB 5 11722
Eitan wrote:
Hello,
I need to create a background thread and two (or more) options are
available to me:
1. BackgroundWorke r
2. Asynch delegate method and BeginInvoke
What are the differences between them in performance, complexity etc.
BackgroundWorke r is easier. Unless you have some specific reason to not use
it, that's probably your best choice.
Async delegate uses the thread pool just as BackgroundWorke r does, but it's
harder to use, will have no difference in performance, and is more complex.
-cd
Carl, Tanks
EitanB
"Carl Daniel [VC++ MVP]" wrote:
Eitan wrote:
Hello,
I need to create a background thread and two (or more) options are
available to me:
1. BackgroundWorke r
2. Asynch delegate method and BeginInvoke
What are the differences between them in performance, complexity etc.
BackgroundWorke r is easier. Unless you have some specific reason to not use
it, that's probably your best choice.
Async delegate uses the thread pool just as BackgroundWorke r does, but it's
harder to use, will have no difference in performance, and is more complex.
-cd
I disagree. If you want to just execute an action, without cancelling
or notification while that action is performing on another thread, then I
would say using an asynchronous delegate call, the Thread class, or the
ThreadPool is much easer than the BackgroundWorke r class.
If you need updates from the background thread, and/or the ability to
cancel, then the BackgroundWorke r is the best option.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:Oh******** ******@TK2MSFTN GP02.phx.gbl...
Eitan wrote:
>Hello,
I need to create a background thread and two (or more) options are available to me:
1. BackgroundWorke r 2. Asynch delegate method and BeginInvoke
What are the differences between them in performance, complexity etc.
BackgroundWorke r is easier. Unless you have some specific reason to not
use it, that's probably your best choice.
Async delegate uses the thread pool just as BackgroundWorke r does, but
it's harder to use, will have no difference in performance, and is more
complex.
-cd
Hello,
Thanks for your anser.
My thead will communicate (send command/recieve status) through the
Ethernet. The status is a byte array, which I need to display on the screen.
EitanB
"Nicholas Paldino [.NET/C# MVP]" wrote:
I disagree. If you want to just execute an action, without cancelling
or notification while that action is performing on another thread, then I
would say using an asynchronous delegate call, the Thread class, or the
ThreadPool is much easer than the BackgroundWorke r class.
If you need updates from the background thread, and/or the ability to
cancel, then the BackgroundWorke r is the best option.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:Oh******** ******@TK2MSFTN GP02.phx.gbl...
Eitan wrote:
Hello,
I need to create a background thread and two (or more) options are
available to me:
1. BackgroundWorke r
2. Asynch delegate method and BeginInvoke
What are the differences between them in performance, complexity etc.
BackgroundWorke r is easier. Unless you have some specific reason to not
use it, that's probably your best choice.
Async delegate uses the thread pool just as BackgroundWorke r does, but
it's harder to use, will have no difference in performance, and is more
complex.
-cd
Nicholas Paldino [.NET/C# MVP] wrote:
I disagree. If you want to just execute an action, without
cancelling or notification while that action is performing on another
thread, then I would say using an asynchronous delegate call, the
Thread class, or the ThreadPool is much easer than the
BackgroundWorke r class.
Then you agree. In the case you describe, you have a specific reason not to
use BackgroundWorke r - your use case does not fit well with the
BackgroundWorke r model.
-cd This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vlad |
last post by:
I have implemented an asyncrhonous execution of a method using the
delegate's BeginInvoke()
I am trying to spin multiple worker threads in a thread pool.
Here is the code:
TestProcess process = new TestProcess(TestProcess);
process.BeginInvoke(args,null,null);
private void TestProcess(args)
{
|
by: Valerie Hough |
last post by:
I'm not entirely sure what the difference is between these two approaches.
In order to avoid reentrant code, I was using Control.BeginInvoke in my UI
to cause an asynchronous activity to be done on the UI's message loop. I
began to get System.ExecutionEngineException errors so (on the theory of do
something different if what you're doing isn't working) I switched to using
delegate.BeginInvoke with the appropriate EndInvoke and the problem...
|
by: ryan |
last post by:
Hi,
I've omitted a large chunk of the code for clarity but the loop below is how
I'm calling a delegate function asynchronously. After I start the each call
I'm incrementing a counter and then making the main thread sleep until the
counter gets back to zero. The call back function for each call decrements
the counter. Is there a better way to make the thread wait until all calls
are complete besides using the counter? I've seen some things...
|
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...
|
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...
| |
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
|
by: =?Utf-8?B?SGVucnk5OQ==?= |
last post by:
What happens here?
The backgroundworker (bgw) unzips RTF-Helpfiles (up to 1 MB in size).
The ProgressChanged-Event gets the unzipped files (to display them in a
RichtTextBox)
It follows the Trace that prints always what bgw has unzipped and what
ProgressChanged received:
1. bgw: HelpFilelistgzip
2. ProgressChanged: HelpFilelistgzip OK!
|
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
|
by: Dave |
last post by:
I wrote a simple Asynchronous Socket client that receives OnConnect
notifications and attempts to report this back to the win forms app.
as the notification method is on another thread i'm using
winforms.Invoke or BeginInvoke but the GUI locks up - seemingly just
after entering ConnectResultInvoked().
i thought this was to be pretty straightforward, but i'm stumped so
far. does anyone know what could be the problem??
here's a...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |