Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on 

VB.Net - BackgroundWorker running multiple

Good Day Experts!

I have finally figured out and have my background worker operating properly.  I am not sure if there is a better way.  Can you confirm if I am doing this the best way?

My project is complete and I am adding the BGW after the fact.  

1) I put a transparent button on top of an existing button
2) On the click of the transparent button I start the BackgroundWorker
3) The BackgroundWorker DoWork contains the call to the original button click

I have 20-30 buttons I would like to utilize the BackgroundWorker on.  Is there a way to use one BackgroundWorker multiple times?  

This is my first attempt at using it and I appreciate your help.

Thanks,
jimbo99999
Visual Basic.NET

Avatar of undefined
Last Comment
Ark
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

>>Is there a way to use one BackgroundWorker multiple times?  
To do the same task?


1) I put a transparent button on top of an existing button
2) On the click of the transparent button I start the BackgroundWorker
3) The BackgroundWorker DoWork contains the call to the original button click

Erm. Why not do the following
Click the original button and in there start the background worker and in the DoWork run the code that you currently have inside the button click event.  (Also if you have NOT coded your current method correctly you haven't gained any advantage of using a background worker.)
SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jimbo99999
Jimbo99999
Flag of United States of America image

ASKER

Hello.  Thanks for responding.  The 20-30 buttons are on a tabControl with over 20 tabs.  The issue is either a data retrieval to a datagrid or the export to Excel from the datagrid takes a "long" time in User terms.  When this happens and they try to move the tabControl to get to other things on there desktop it leaves a white trail where it use to be.   So, with the background worker I was able to get rid of that behavior and make them more productive by being able to timeshare.

I was trying to not disturb the original functionality as best I can.  I was thinking with the transparent button over the original button
that has a standard naming convention(btnExcelOrderT) then I know the button under it is named btnExcelOrder). The would allow me to pass the name of the button to the DoWork of the Background worker then call the button click of the button.  I am trying to do this without having to add code or move the code of the button click to the DoWork of BGW.  

But it feels like this is not possible without making multiple BGW's.
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Sounds like the answer to my question was 'no, different tasks'.
If that is the case then you code one BW per task.  

ps. I'd move the code into the DoWork function and not use transparent buttons.  Your design looks like using sticking plaster rather then fixing it properly.
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo