VS 2008 Thread Abort Exception While Using Background Worker

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


ADVERTISEMENT

VS 2008 Terminate A Threading.thread Using Thread.abort?

Jun 10, 2010

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).

View 2 Replies

Serial Use Of A Background Worker Thread?

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

Background Worker Create Second Thread For Progress Bar?

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

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

Background Worker - Cross Thread Operation Not Valid

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

Background Worker Combox Cross-thread Error

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

C# - Background Worker In External Reference (DLL) Locking Main Thread?

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

Unhandled System.TargetInvocation Exception Using Background Worker

Mar 29, 2012

I am experiencing a mysterious unhandled 'System.TargetInvocation exception' whil using background worker. Follwing are the logged in event viewer when the application resulted in unhandled exception.

.NET RunTime:
Application: MyApplication.exe
Framework Version: v4.0.30319

[Code].....

View 1 Replies

VS 2010 Background Worker Cross Thread Operation On Active MDI Child

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

Abort Menthod Of Thread Class Is Not Aborting The Thread?

Apr 1, 2010

I am using vb.net 2005In my form load procedure I am starting a background thread.The thread is declared as public.

Public
threadMonitorWMI As System.Threading.Thread
And started in form_load

[code].....

View 2 Replies

Synchronize The Timer Event So That The Timer Executes From The Background Worker Thread?

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

VS 2008 Background Worker?

May 7, 2010

I'm new for VB.Net 2008. I am facing some problem about how to make the multiple groups activities running (it might concurrent) based on their own activity's time set? For example: If there is 80 groups and 100++ activities in each group, can i use background worker (create 80 background worker?) to handle this (each background worker handle their group activities.) if in this case (But it will running lag or hang)

View 14 Replies

WPF Background Worker Not Recognizing Worker Object

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

Multithreading - .NET 2008 Background Worker?

Apr 14, 2011

I have created a background worker using a tutorial. I understand some basic stuff like how to update a label or a progress bar from inside of it. The purpose of this background worker is setup a bunch of variables that are going to be used by several other background workers later. The variables i am setting up are 6 different lists and a multi-dimensional array. The code looks like this for the background worker at the moment.

Private Sub My_BgWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles My_BgWorker.DoWork
For i As Integer = 0 To m_CountTo

[code]....

I would normally use the persons.add to add something to the list, but I'm having a really hard time wrapping my brain around an easy way inside of the backgroundworker to add new values to several different lists(which are going to vary in amount of data values). Is there an easy way to do this? I'm used to just having invokes at the top of a sub to do this but those don't seem to work inside of a dowork sub.

View 1 Replies

VS 2008 Background Worker Apartmentstate

Nov 11, 2011

I have written a code in background worker which calls a function written in a module. In that function I create an object of an existing form. But on doing so I get error "Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."[code]

View 6 Replies

VS 2008 Timer And Or Background Worker?

Nov 16, 2010

I want my progress bar to go down as time gets closer to it's next "event", so i guess i need a background worker for that so it uses another thread.How can I get that to loop on a timer so something so i knows where it's zero value will be and where it's current vlaue should be.

View 12 Replies

VS 2008 - Slow A Task In The Background Worker Down?

Nov 5, 2010

Can i slow a task in the Background Worker down?

View 2 Replies

VS 2008 Cancelling Progress Background Worker?

May 5, 2009

I am using the code below to login to a softphone. However, the login progess is a long process as there are many things that have to be initialized and checks to be made, I have only put a few on here, as it would make the code to long to post.In the code below I am checking if the CancellationPending if the CancelAsync has been called in my cancel button click event, before doing each check. Is this correct? Also if the check fails I also call the CancelAsync and set the e.Cancel to true.

Private Sub bgwProcessLogin_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
'
' * Perform at test to see if the background worker has been

[code].....

View 1 Replies

.net - Thread.abort Hangs Forever

Sep 15, 2011

Code to launch a wmi query on remote computers. This code runs in several threads at the same time.

[Code]...

For Each objMgmt In oquery.Get 'on some pesky windows XP machines this line hangs forever regardless of the timeout and the thread can never be used to get info from another computer. the only way to "release" this is to reboot the target computer.

[Code]...

View 1 Replies

Multithreading - .NET 1.1 Safely Abort Thread?

Feb 10, 2011

I'm trying to safely kill a thread. In my button click I have:

try
dim bar as new foo()
dim mythread as New System.Threading.Thread(AddressOf bar.Start)
mythread.Start()

[code]....

When it goes to abort the thread I still get a thread abort error.

View 1 Replies

VS 2008 - Background Worker Code - Does Not Shows The Result

Jul 30, 2009

I am using a background worker, it runs fine but it does not shows the result. i am using jmcilhinney source to work it out.. have a look.

VB Imports System.ComponentModelImports System.Text.RegularExpressionsImports System.NetImports System.IO Public Class WorkDialogue Private _result As Long = 0L Public ReadOnly Property Result() As Long Get Return Me._result End Get End Property Private Sub

[CODE]...

And the button codding in other form:

VB Using dialogue As New WorkDialogue dialogue.ShowDialog()TextBox2.Text = dialogue.Result.ToString() End Using

View 5 Replies

VS 2008 - Stopping And Starting Timer In Background Worker

Oct 18, 2009

I have a background worker which runs, at the start it stops a timer which has it's interval set to 500ms, at the end of the bgworker sub it starts it again. I've debugged and found out that the line that starts the timer up again (tTimer.Enabled=True) runs. However the timer does not resume. I'm don't know, but I'm thinking perhaps because I'm stopping and starting it on another thread it's not resuming properly or the sub it was attached to (via AddHandler) has been reset or something so it's running but not running the code in the sub it was attached to. If I never stop the timer in the code, it continues to run just fine, but I need it to stop at the start.

View 2 Replies

C# - Abort A Thread Started With Delegate.BeginInvoke?

Feb 1, 2010

Disclaimer: I know that Thread.Abort is evil. I'm using it as a last resort since some I/O functions (e.g., File.Exists when used on a non-existing network share) block for a large amout of time and do not allow you to specify a timeout.

Question: Is it possible to Abort (as in Thread.Abort) a worker thread started using Delegate.BeginInvoke or do I have to do the Thread handling myself?

View 2 Replies

Multithreading - Load Data In Background Mode Using Background Worker?

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

Write In Worker Thread In A Data Table And Rich Text Box in Main Thread

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

VS 2008 Running A Thread In The Background?

Jun 9, 2009

Im trying to run a thread in the background. The sub would take a string as as input and the text to speech object would read the string.

1st problem is: How do I pass my value strIn to my sub SpeekEventWorker when im calling it like this

[code]...

View 10 Replies

VS 2008 Messagebox From Background Thread But Tied To UI

Jun 14, 2010

Currently I have a background worker doing a bunch of stuff and if a condition is met, it throws up a MessageBox for the user to pick from an the background thread pauses like I need it to, however most of the time the Messagebox shows up behind the main form (which is on the primary app thread, the UI thread) and I'd like the BW code to pause until it's acknowlegded and I also want the MessageBox to be owned by the main form (so it's always displayed in front and you can't get to the main form until you acknowledge the MessageBox. Later I'll be changing the MessageBox to be a modal form that matches the app's theme (I'll be opening this form using .ShowDialog()) should I go ahead and make that form now?

View 20 Replies

Using A Background Worker?

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

What Is A Background Worker

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







Copyrights 2005-15 www.BigResource.com, All rights reserved