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

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 4297
"Jesse Aufiero" <ja******@moaboil.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.ja.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
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
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,...
7
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...
6
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. ...
8
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...
4
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...
7
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...
2
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
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
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...

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.