473,800 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

background worker in vb.net 2005

I'm wondering what the rule is on how to assure that the background worker
'DoWork' routine is truly running entirely in the background. My DoWork
routine calls another procedure which resides in a shared class. This other
procedure has local variables but also refrences class level variables. I'm
wondering if this might cause the DoWork routine to have to reach out to the
primary thread, thus greatly slowing down the routine.

How can I assure the routine is truly running entirely in the background,
and not having to reach over to the primary thread for any reason?

Thanks!
Jul 6 '07 #1
4 4316
"Jesse Aufiero" <ja******@moabo il.comschrieb
I'm wondering what the rule is on how to assure that the background
worker 'DoWork' routine is truly running entirely in the background.
My DoWork routine calls another procedure which resides in a shared
class. This other procedure has local variables but also refrences
class level variables. I'm wondering if this might cause the DoWork
routine to have to reach out to the primary thread, thus greatly
slowing down the routine.

How can I assure the routine is truly running entirely in the
background, and not having to reach over to the primary thread for
any reason?

Thanks!
What does "reach over" mean? If you access/modify the same data on both
threads, you have to implement a synchronization mechanism, but that's
always true with multi threaded applications.
Armin

Jul 6 '07 #2
Jesse Aufiero wrote:
I'm wondering what the rule is on how to assure that the background worker
'DoWork' routine is truly running entirely in the background. My DoWork
routine calls another procedure which resides in a shared class. This other
procedure has local variables but also refrences class level variables. I'm
wondering if this might cause the DoWork routine to have to reach out to the
primary thread, thus greatly slowing down the routine.

How can I assure the routine is truly running entirely in the background,
and not having to reach over to the primary thread for any reason?
Copy the "worker" class/method out into a [new] Console Application and
call the "DoWork" method from Sub Main.

If this console app. compiles cleanly then your "worker" is nicely
self-contained.
If not, then it'll complain about all the stuff that it needs to "reach
back" into the enclosing class for, opening you up to contention problems.

HTH,
Phill W.
Jul 6 '07 #3
if i ported everything out, i'm sure it would run just fine, but when placed
back into the solution, i'm uneasy about how a shared function or sub in a
class is handled by the background process. might it reach out to the
primary thread in this case? not sure how to test this.
"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:f6******** **@south.jnrs.j a.net...
Jesse Aufiero wrote:
>I'm wondering what the rule is on how to assure that the background
worker 'DoWork' routine is truly running entirely in the background. My
DoWork routine calls another procedure which resides in a shared class.
This other procedure has local variables but also refrences class level
variables. I'm wondering if this might cause the DoWork routine to have
to reach out to the primary thread, thus greatly slowing down the
routine.

How can I assure the routine is truly running entirely in the background,
and not having to reach over to the primary thread for any reason?

Copy the "worker" class/method out into a [new] Console Application and
call the "DoWork" method from Sub Main.

If this console app. compiles cleanly then your "worker" is nicely
self-contained.
If not, then it'll complain about all the stuff that it needs to "reach
back" into the enclosing class for, opening you up to contention problems.

HTH,
Phill W.

Jul 6 '07 #4
Jesse Aufiero wrote:
if i ported everything out, i'm sure it would run just fine, but when placed
back into the solution, i'm uneasy about how a shared function or sub in a
class is handled by the background process. might it reach out to the
primary thread in this case? not sure how to test this.
I think what I meant was that you /shouldn't/ "port everything out".

The "worker" method should be as self-contained as you can make it.
Anything /else/ that you have to copy across to get it to compile and/or
work is something you need to worry about, i.e. either you have to
eliminate the need for it, by giving the worker more information up
front or you have to add synchronisation code around it.

HTH,
Phill W.
Jul 9 '07 #5

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

Similar topics

4
22630
by: John Veldthuis | last post by:
I have set up a background worker and now find I need to give it multiple arguments. What is the best way of doing this? An example would be nice.
1
1787
by: bilosta | last post by:
I need help with background worker and form I have a class (form1) that works with database. I need this: -Show form2 while form1 is geting data from database -When form1 is done, close form2, proced working form1 I try these things with thread but a can not do it I try it with background worker, but I dont know how:(
7
10072
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works great, at least on my system. The reason I am doing this is some customers are pulling from VPN connections which are slow. This allows the list of rows in the data grid to appear a little quicker while the list which are not used as soon load in...
6
5965
by: sjoshi | last post by:
I'm able to use the Bacground Worker class to execute task and pain the UI. However I want to be able to execute n tasks in order, say n1, then n2 if there were no errors during n1, n3 so on. I'm wondering what would be the best way to do this , do I wait in a do...while loop for each to finish and then start another ? thanks Sunit
8
5372
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In this code there is a panel panel1, that I populate with a lable in the foreground. Then when I click on "button1" a backgroundworker thread in async mode is started. When the backgoundworker thread completes the thread returns a panel to populate...
4
2414
by: csharpula csharp | last post by:
Hello, Can you please tell me if I should use the background worker in the following way: if (worker.IsBusy) worker.CancelAsync(); (or I can avoid this if)? And in case I want to restart the background worker ,should I do it this way? worker.RunWorkerAsync();
7
3020
by: csharpula csharp | last post by:
Hello, I got a question regarding the usage of background worker. How can I run few threads via background worker with different objects as parameter each time. I understood that I can't do this: for (int i = 0; i < inputNum; i++) { string param = i.ToString();
2
5800
by: thoffman | last post by:
Hello again everyone! I have an issue that I can't seem to find a straight answer for anywhere... I have a For loop that sends a file name to a background worker that contains some long running code and I can't find a way for the parent thread to wait for the background worker to finish... Here is the example code: For i = 0 to 4 BacgroundWorker1.RunWorkerAsync(fileName(i)) Next Private Sub BackgroundWorker1(ByVal sender As...
1
2043
by: Infog | last post by:
I am trying to code a simple background workers class without needing to use the backgroundworker object on a form. This would allow me to use a background worker in any class without writing much additional code. Is it possible to pass in the name of a sub at runtime instead of hard-coding it? To do this I would replace onDoWork and onProgressChanged below and use (Byval onWorkSub as SomeKindOfObject?, Byval onProgressChangedSub as...
0
9551
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
10505
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...
0
10275
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...
0
10033
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
9085
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
7576
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
6811
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
5471
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
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.