C# - Difference Between BackgroundWorker And System.Threading.Thread
Oct 24, 2009What is the difference between creating a thead using BackgroundWorker and creating a thread using System.Threading.Thread?
View 2 RepliesWhat is the difference between creating a thead using BackgroundWorker and creating a thread using System.Threading.Thread?
View 2 RepliesI'm creating an app that needs to navigate to multiple websites, logs me in and then submits my documentation.I've read that multi-threading can handle this task but then I've read something about backgroundworker.
View 1 RepliesI have this little application that is using a System.Threading.Thread.Sleep, application runs great but Windows thinks the application is not responding even though it is running.
[Code]...
What is the difference in using: BackgroundWorker1 or System.Threading.Thread
View 3 RepliesI want to have My.Settings.Delay in seconds not milliseconds adding the 000 for the user. I tried My.Settings.Delay + 0 + 0 + 0. but can't sort how to do this.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim var As Integer
Dim startVal As Integer
[code]....
I cant get System.Threading.Thread.Sleep to work..[code]
View 2 RepliesI have a string in which for sure there is a date in the following format: YYYYMMDD. So, to identify 14 October 2009 I'll find 20091014.Having this string, how can I format into System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern?
View 4 RepliesWould anyone be able to help me here please. I'm fairly new to VB.net and threading so im just trying to figure out what is happening.When I debug this I am getting the error thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on.
I'm a little lost as to why the error is occuring or how to fix it. I've had to put the progress bar in a separate thread otherwise the GUI crashes
[Code]...
Currently I'm using System.Threading.Thread.Sleep(5000) to let my app pause/sleep for some time. This works great but I can't open my app anymore when it's sleeping and it uses about 25% of my CPU. I guess there must be a better way to do this. I also tried using a timer but that didn't work out to well for me..
View 5 RepliesI've been trying to use "System.Threading.Thread.Sleep(15)" as the delay code but if freeze the form. I used this "Location.Refresh()" where location is the name of the form, but it didn't give me what I need. This code is going to work on a ProgressBar while typing and the value of the progress bar change while typing. The progress bar jumps to the new value and I want it to move. So I thought about puting it in a "For ... Loop" but the whole form freezes.
[Code]...
I have 5 Picture Boxes, each picture box has an image but all 5 of them has a visibility of false. I have a button, when clicked will show 5 of the images. But showing the 5 images with a delay. So it's going to be
[Code]...
A BackgroundWorker thread can pass data to the primary thread. It does it via the RunWorkerCompleted and ProgressChanged events, which I believe run in the primary thread. I would like to encapsulate the BackgroundWorker control in a class so that I can instantiate it more than once. But I don't know how the BGW can then communicate with the primary thread. If the BGW control is within a class, it does not have access to the properties outside the class. In that case, how can the BGW pass data to the thread that instantiated it?
[Code]....
im trying to terminate a threading.thread using thread.abort the thread runs a download connection so is usually in the middle of socket.recieve or socket.send or socket.connect when aborting i just want to terminate the thread no matter what thread.abort raises an MDA excpetion. so i ticked it off in the debug exceptions menu. now it doesnt raise an exception, but the thread simply wont terminate. my program wont close unless i press top in the debugger.i cant pause downloads because i cant terminate the thread this code wasn't working?
Dim vT As Threading.Thread
For Each vT In clsDownloader.DownloadThreads
If Not vT Is Nothing Then
vT.Abort()
[code].....
as for the exception concerning threads being aborted from other threads being dangerous, how is it possible to send a message from a main thread to another thread to abort itself? as far as i know the only way to a abort one thread from another is to just kill it (because i dont know of ways for a thread to communicate with another).
I'm working with BackgroundWorker, I want the BackgroundWorker do the retrieval process of data from database while the user can still do another task on the form. The problem is, after retrieving the data, I can't seem to access the ListView in my Form from the DoWork event of BackgroundWorker, I will populate that ListView using the data I've retrieved.
Consider this example, this is how I'm doing it:
Public Class Test
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[Code].....
How do run processes synchronously from a thread or backgroundworker thread? Is it even possible?We have program that allows the user to download several files from a remote server, compress them, and then email the files.It has several long running processes that must run in order. We want these to run on a separate thread so as not to make the form unresponsive. Does a way exist to do this? We attempted a rather clumsy way of approaching this problem by using background worker threads. When each thread is completed and returned back to RunWorkerCompleted, we start another background worker thread and repeat the the next process. It works somewhat but seems to take a lot of resources to run.
View 1 Repliesi'm trying to do a database search in my WPF program. And to give the program some speed, I want to use Backgroundworker or Threading. The problem is that i have to invoke the controls that the new thread is going it access. But i don't know to do this and i don't know i which event to put the code. Here is some code:
[Code]...
I would like to know what are the usages for Threading or BackgroundWorker, and their implementations.I currently am running a UDP program, but the server freezes until the client sends the packet, which momentarily unfreezes the server, and then re freezes it.I have looked at the MSDN for them and they seem complicated :l
View 26 Repliesthe differences between multi threading and background worker and when I should be using either.
View 3 Replieswhat is the difference between a task and a backgroundworker? when it is better to use one and when the other?
View 1 RepliesI am using a class with below code, the question is how to update the label's value at UI thread from the backgroundworker?
Imports MySql.Data.MySqlClient
Public Class clsBackGroundWorker
[code]....
im sorry if this has been asked before.but i couldent find it in my first look i have a form that runs a query on a mysql database but as it runs the query the form stops responding till it finishes sooo i had the smart idea of putting it in a back ground worker..
GREAT i thot i had it working it all seemed to go greeat then i noticed when i try to change the label text on the form to corispond to the info it got... it wont work it give me a cross threading error....
how to cross thread between the back ground worker and the origial form..
I wanna sleep a second thread of BackgroundWorker. I tried to use Me.Dispatcher.Thread.Sleep(500) in DoWork event, but it fails.
View 3 RepliesI have some classes right now that I have that I reuse for Client/Server programming. I'm using Thread in these classes though for monitoring for things being written to the network streams and stuff like that. I'm just not sure if I should be using the background worker class instead. I'm also using TCPClient and Listener classes, should I be using sockets directly? I guess it would all depend on the flexibility I would need in a given application's specs.
[Code]...
I am writing an 'Admin Console' that accesses hMailServer via its provided COM interface. I am using Visual Basic 2010 Express. In one procedure, it scans for the whole accounts. Because it's a lengthy procedure, I shove it into a set of BackgroundWorker threads.
First result: A maximum of 19 simultaneous threads, with 36 seconds total time.Then I rewrote a time consuming thread initialization code segment, and managed to reduce the time required to approximately 14 seconds... but the thread count now hit 330 threads!Will that huge amount of threads be detrimental? E.g., causing out-of-memory exceptions &c. ?
I am using the BackgroundWorker to do the heavy tasks so the UI thread doesn't get blocked. While the BackgroundWorker can send values to the UI thread using the progress-scheme, how can the BackgroundWorker get some values FROM the UI thread?
Either by asking it or simply by the UI thread sending some values to the BackgroundWorker?
Just accessing a variable of the UI thread like UIForm.x within the BackgroundWorker does not work, it does not seem to have access to the UI variables?
I have a background worker that's checking the status of four services on a remote server.This is setup on a timer (5 Seconds) as below. For some reason it's hanging the UI thread causing the application to 'lock' for a second each tick, I cannot work out why?!
Private Sub ServiceTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ServiceTimer.Tick
_ServiceBGWorker = New System.ComponentModel.BackgroundWorker()
[code]......
Well to simplify it, whenever I use sendkeys from a background thread it just doesn't work. I even created a textbox, button, and backgroundworker with the following code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[Code].....
I'm running some tasks on a BackgroundWorker thread and needed to display the current tasks in a label.Before adding the label, the tasks were completing just fine and the UI was responsive.Once I added the labels, the UI has become unresponsive. The issue, I believe, is the Invoke property.I've declared all my tasks, including the updating, in a sub and am getting the Invoke property of the label each time, in order to set the information.The following is an example of what I'm doing:
VB.NET
Private Sub Test()If lblTask.InvokeRequired = True Then Dim mi As New MethodInvoker(AddressOf Test) lblTask.Invoke(mi)
[code]....
I am trying to pass some status from a IP call in a shared sub to a label on my form. This is the current code that i am using:
[Code]....
i got inside
WebBrowser1_DocumentCompleted sub
the code below
WebBrowser1.Document.GetElementById("form").InvokeMember("click")
Call ProcessNextLine()
when it clicks this button it should load another page(Like log in)
Call ProcessNextLine()
takes next line from txt file (It's url) + navigate
but I want it to wait let the page load before calling "Call ProcessNextLine()" I tried System.Threading.Thread.Sleep not working?