VS 2010 Standard Thread Vs Background Worker?
Apr 25, 2012
I have a application which processes 1000's datas.. for each processing it needs to update gui and db and many variables in my application. So what i have planned is to use 50~90 background worker with my own algorithm of thread pool, synchronization and thread close.So here is it efficient in terms of memory and performance. just confused what to use.. backgroundworker componenet or standard thread.
View 11 Replies
ADVERTISEMENT
Dec 11, 2011
how to put this on a background worker without getting cross thread errors??? trying to upload a childform object values to an access db.I don't work in IT,Our company's LAN so slow that it takes around 3~5 seconds trying to update/insert values in access using the code below so putting it on a background worker i think makes the app immediately usable once save/upload's called unless otherwise somebody could suggest a faster way to speed things up.[code]
View 2 Replies
Apr 6, 2012
I have a BackgroundWorkerThread which I want to use serially.So some of the code in the UI thread will look like this [code]But of course I can't do the second RunWorkerAsync until the UI thread has seen the RunWorkerCompleted event indicating that the "Sequences" work has been completed (or somehow knows that the "Sequences" work has been completed).So I need some sort of synchronization between the two RunWorkerAsync calls, but whatever I use cannot hang up the UI thread because it has to be able to handle ProgressChanged events.Maybe the RunWorkerCompleted event could make the second call but I really don't like that structure.So how do I delay the second call to RunWorkerAsync (for the "Templates" work) until the background thread has completed the "Sequences" work?
View 6 Replies
Apr 6, 2011
I have searched the forum and found several forums related to the backgroundworker thread but have been unsuccessful in finding my answer.My objective is to display an animated gif or progress bar while the program is executing a particular method which can take upwards of several minutes to complete. I cannot get the second thread to run the progress bar while the main progrem is executing the time consuming method. I have created a demo based on another thread and can't seem to get it to create two threads. I was attempting to get the backgroundworker to execute the progress bar while my main code runs on UI thread.
[Code]...
View 10 Replies
May 30, 2011
I am testing a background workder. I am running the following code for the test.
Private Sub bgwTest_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwTest.DoWork
Dim a As Integer = 0
Do While a < 10 'Infinite loop
ComboBox1.Items.Add(1)
[Code] .....
But this code generates the following error:
"Cross-thread operation not valid: Control 'ComboBox1' accessed from a thread other than the thread it was created on."
View 2 Replies
May 19, 2010
Can someone tell me how to get the selected text in the combo as it encountered cross-thread in the following code:
[Code]...
View 5 Replies
Aug 6, 2010
I'm working on a web application that uses the web browser control to get and set info from my website. The content on the site is pulled from different pages and the data the application stores becomes really huge so i used a background worker to do the work and keep the form responsive. On each loop i call to get the webbrowser's inner html so i can sort through it and grab what i need and it works; but only the first time!? After i call it the first time and try to call it again to update the variables the function hangs and then the console shows me a Thread Abort Exception, The try statement i used to contain it doesn't fire off an exception. When i debug the program and i get to that function, it hangs and then just stops working.
The function that loops:
vb.net
Dim ids As String = GrabIDs()
Dim IDCount As Long = ids.Split(CChar(",")).Length - 1
Do Until IDCount = 0
[Code]....
View 1 Replies
Mar 21, 2011
I use background worker almost daily and works great. Today I came to an instance though where I needed to put my background worker in a separate project then the one I was running because I needed to use this class in two different projects in my solution. When I tested the coding on a winforms form, it works perfectly, handling my coding on the background thread. When I try to reference this class from an external project, all of my coding seems to run just fine, but it does not appear to be doing anything on a background thread as it should be, causing my main window to lockup.
Is there any way around this / what is the best practice for ASYNC calls in an external class.Note I basically created a class that u call start, and an event fires when data is ready, so it's not like my external project is waiting for the method to complete.
Solution ABC has two projects. Project A and Project B. Project A is my WPF application and B is my DLL doing the work. Inside project A I have
Dim SmartCardData as new Solution.B()
SmartCardData.Start()
Project B has a sub
[code]....
View 3 Replies
Apr 23, 2009
I have a windows application that need to process som quite time consuming jobs. In my first try i did all processing under
the form thread. The result was bad response and update of the form due to the heavy jobs.To get around the problem with bad response from the form i created a new class "processing" where i put all the data processing. Then i instanciated a background worker where i in the "doWork" sub created a new instance of "processing".The "processing" class creates a timer from system.timer, and the timer drives the processing.On the Timer event Elapsed the timer starts a new thread from the thread pool.
My problem is now when i want to asynchronously close the background worker (with the corresponding function call what ever it is called ...) there is still a timer thread out there that causes exceptions for me.
1. How can i close my background worker and at the same time have the timer to be stopped?
2. Is there a way to synchronize the timer event so that the timer executes from the background worker thread?
3. Is there a better approach for me to adapt?
View 3 Replies
Nov 10, 2011
I want to use a background worker control in my application, and have it report progress to a Progress Bar It will download data and stuff, and I want to be able to change the text on a label.
View 2 Replies
Aug 17, 2011
i want background worker to use file copy, how?
View 1 Replies
Feb 19, 2012
I have some code that gets the documenttext of the current page in the browser, the trouble is that im trying to use it in a backgroundworker so the ui remains responsive. Everything works fine as is If I run from a button click event, but in the background worker I get errors when trying to use the webbrowser.
'if urltocheck is blank use hidden webbrowser to get page text
If urltocheck = vbNullString Then
'make sure browser isnt already loading
[Code]...
Thats the code how do I make these calls the the browser from the backgroundworker? Or how I can I run an enormous for loop from the ui thread, and still keep the ui responsive?
View 2 Replies
Jun 19, 2012
It's always been my understanding that ByVal means is that you are passing a copy of a variable to your Subroutine. You can make changes to the copy and the original will not be altered.So if that's true I have two questions- How is my DataGridView updating without me passing the arguments back to it- The backgroundworker works fine as long as I don't reorgnize the columns in the datagrid.
'I pass the rows of my datagridview to the background worker
bgwGetHostStatus.RunWorkerAsync(dgvMonitoredSites.Rows.Cast(Of DataGridViewRow).ToArray)
'It grabs a website name from the IP column and reports if it's down or not in the status column. Now if
[code].....
View 2 Replies
Aug 25, 2011
I i'm attempting to add child nodes to a treeview inside a background worker's doWork() method.
I'm getting an exception because I'm in a different thread, and need to use the invoke() method.
Can anyone point me in the right direction?
View 3 Replies
May 27, 2012
I'm getting a Cross-thread operation not valid error when my label text changes - this is very strange because it was working up until yesterday.The only way I can get this to work is by applying the invoke..[code]Is there a more simpler solution or will I have to invoke all my label coding?
View 9 Replies
Mar 11, 2009
I have the following code that adds a background worker into a VB.net WPF project:
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.BackgroundWorker
[Code].....
And I get the following error for the DoWork worker event:
Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
It seems like it's missing something in the Event declaration, but can't find it.
View 3 Replies
May 3, 2012
I am using query from a SQLite database as the AutocompleteCustomSource for a ComboBox. Also, I want to load data in separate thread. My LoadData method works fine when called directly, but it fails when it is called from the BackgroundWorker thread. When it is called from the background thread, it throws a Specified cast is not valid exception on the csearch.AutoCompleteCustomSource.Add(hh("Taj")) line. Below is my code:
Sub LoadData()
Dim connetionString As String
Dim cnn As SQLiteConnection
[Code].....
View 4 Replies
Mar 4, 2009
I'm creating a Client Server application which involves theServer running some scripts in clients and getting back results in an automated way. In Server, other than Main thread, i have 2 worker threads, a) one monitoring response from clients and b) the other scheduling next available job to respective client which executes that job. The issue here is ,I want these worker threads to write the status of their work in the UI(which comes under Main Thread). Also i need to write things in worker thread in a Data table and Rich Text Box in Main thread. But, I can't do so, since it has been blocked to access one thread's function or property directly from others. Is there any work around to do this?
View 8 Replies
May 16, 2012
I have a an idea of how a background worker works but I was hoping someone could give me some advice. If I run a background worker, and in the Do work if I run some coding which edits a file, and in the RunWorkerCompleted I display a label to say "Done". Will the label only say done once the coding for editing the file has completed OR do i need to put this code inside a process or something similar? and the label will only say done once it says process. close?
View 5 Replies
Nov 6, 2011
When I run the following code in the UI thread, it works without issue.
VB.NET private timer as new timer public sub test()timer.enabled = true timer.interval = 1000 timer.start()addhandler timer.tick, addressof timer_tickend sub private sub timer_tick(...) messagebox.show("fff")end sub
But if I run it within a background thread, nothing happens.
View 15 Replies
Jul 15, 2011
I'm writing an application in Visual Basic Express 2008, part of the function being to walk through a folder structure starting from a user specified folder. In my research, I found this thing called a background worker which seemed an appropriate tool to use given the potential size of a target folder structure. I successfully installed the two examples from the library here, and believe I understand the principles involved. Even so, having tried to build this feature into my application, it seems as though it is not working as expected, and, as predicted, debugging a multi-threaded application is a pain in the extremity.
I have this fragment under my "start" button click event -
HomeSource.Enabled = False
HomeCopy.Enabled = False
HomeReport.Enabled = False
[Code].....
View 16 Replies
Jul 18, 2010
im thinking just because an app has been sent ton system tray does not mean its a "back ground worker"
View 1 Replies
Jun 7, 2012
my backgroundworker as I just cant get it to work. Basically I have a backgroundworker which does a few tasks but I'm trying to implement a progress bar and a label. I'm going to set the maximum value of the progress bar to 10 and then have it updating as I move with each task, also I'm thinking of a label with the progress bar which will display the progress ie
[Code]...
View 2 Replies
Oct 7, 2009
I'am trying to make app that will show every file in C:[code]Now how can i add progress bar with the background worker.
View 31 Replies
Nov 20, 2008
I have a background worker that used to fire its RunworkerCompleted event when its DoWork routine finished querying a database and writing its output to a file. The bg worker was in a class called Query, which was called from another class called Trigger. A new Trigger Class was created for each monitored event. In this class, there was a structure which stored the config of each Trigger. When this event was triggered (set to TRUE) a new query class is created and it is passed the Trigger class. When the database query, file writing was done, the query class and all its rsources were diposed from the RunWorkerCompleted EventRecently I changed the application so that a new trigger class is not created for each monitored event. There is a single instance of the class but new config structure for each event. When a particular event is trigger, jsut the config structure is passed to a new query class and the sma ething is done in the query class. I just noticed now that the RunWorkerCompleted event is not being fired anymore.
View 5 Replies
Apr 15, 2009
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 4
BacgroundWorker1.RunWorkerAsync(fileName(i))
Next
[code].....
View 2 Replies
Sep 21, 2009
I have run into this before, When I develop a form to use a background worker to fill tableadapters, the background worker does fine on machines running Vista, but if you run the same thread on an XP machine, the thread gets hung.All the thread is doing is filling a table adapter like this.[code]Why would this run on a Vista machine and not an XP machine?
View 1 Replies
Apr 27, 2010
I have created a background worker to go and run a pretty long task that includes creating more threads which will read from a file of urls and crawl each. I tried following it through debugging and found that the background process ends prematurely for no apparent reason.
While Not myreader.EndOfData
Try
currentRow = myreader.ReadFields()
Dim currentField As String
[code]....
This first bit of code is the loop to input from file and this is what the background worker does. The next bit of code is where the background worker creates threads to work all the 'landingPages'. After about 10 threads are created the background worker exits this sub and skips the file input loop and exits the program.
Try
For Each landingPage As String In landingPages
pgbar.Timer1.Stop()
If VisitedPages.Contains(landingPage) Then
[code]....
Also my main thread runs a forms from where this background is called to run but the main thread is supposed to wait for the background process to end unless the user selects another option from the main form.
View 1 Replies
Jan 11, 2012
I've been experimenting with background worker to maintain responsiveness and to allow the UI to update while things are being done in the background.I've been having problems getting the background worker to do anything with form controls.For simplicity lets say I have form1 and form2.The background worker is on form1Initially I couldnt get it to edit controls on form1 but by using [code]However the problem came when I tried to get the same background worker to update controls on form2, in this case a text box. With the above code there is no error but it also does not update the text box.Is there an easy way to give a background worker access to multiple forms.
View 4 Replies
Mar 10, 2011
i m trying to kill a background worker in the do work event of the worker i was using
backgroundworker.CancleAsync()
but its shows an error saying tat CancellationPending does not allow
how can i kill a background worker after its work gets completed in its do work event
View 1 Replies