473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[C#] One BackgroundWorke r for many tasks

1 New Member
Hello!
I have a Windows Form with many buttons which do different time-consuming things. Currently, for each of these operations I have a separate BackgroundWorke r, but it would be better if I had only one, since I'm not going to have two BackgroundWorke rs run at the same time.
Is it possible to use only one BackgroundWorke r, and changing the DoWork delegate each time?
I've seen that DoWork can be changed only via the += and -= operators, so it seems to me that if I want it to perform a single operation, I have to remove the current one set for DoWork (which means I need to store the last operation executed by the BackgroundWorke r).
Any suggestions?
Thanks!
Oct 24 '08 #1
0 1020

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2229
by: JHoletzeck | last post by:
Is it possible to set the stack size for the thread created by BackgroundWorker like in the API call _beginthread? If not is the stack size a default or the one I set for the whole application? (What I need is a worker thread with a rather large stack in a Windows Forms app complied with /clr:pure) Cheers Jürgen
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...
0
1598
by: andycee | last post by:
Hi, I'm working on an app to filter images (by size, EXIF info etc..) and display as a slideshow. To allow the worker thread to continue running whilst performing the longer tasks such as loading the image and reading the EXIF data, I have put my code for finding the next image in a BackgroundWorker thread. My problem is that this code accesses several ListViews and variables in the UI thread, and also needs to write to some labels and...
2
2612
by: jimmy | last post by:
Does someone know why BackGroundWorker.ReportProgress method doesn't accept strings ? You can't pass integer always for a progress meter as percentage completed cannot be calculated in many tasks like logging on to a remote computer. In that case, we would like just to show a message "Logging on".... Any ideas ??
5
11237
by: redear | last post by:
Is there a way to immediately terminate a BackgroundWorker thread? My problem is that the BackgroundWorker starts with a call to My.Computer.FileSystem.GetFiles that can run for a very long time if it is pointing to a directory tree with many files. If the user requests cancellation during this time, the main thread can call CancelAsync and can post a "Cancellation Pending" message to the user, but the BackgroundWorker cannot respond to...
4
1578
by: BR | last post by:
Hi, I am writing a small utility to perform system maintainence tasks on Windows. In this, I am launching a MMC snapin as a process using BackGroundWorker and using the "RunWorkerCompleted" event handler to know when the snapin was closed. This works fine on Xp and Vista 32 bit and the RunWorkerCompleted event handler is called when the snapin is closed. But on Vista 64, the RunWorkerCompleted event is called as soon as the snapin is...
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
1841
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
1
967
by: AAaron123 | last post by:
Is the following OK in Backgroundworker: Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles backgroundWorker1.DoWork Static index As Integer = 700 Dim filename As String filename = "Image_" & index.ToString("D4")
0
9685
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
9533
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
10461
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10190
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
9057
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
7555
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
6796
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();...
0
5447
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...
3
2928
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.