BackgroundWorker and RunWorkerCompleted event

G

Guest

I have a BackgroundWorker component that I am using as:

Dim arguments As XmlSentArguments = New XmlSentArguments
arguments.TransactionId = 10
arguments.OrderId = "na"
workerThread.RunWorkerAsync(arguments)

The thread seems to get started and it completes. I put a breakpoint in
DoWork that looks like:

Dim worker As BackgroundWorker = _
CType(sender, BackgroundWorker)
e.Result = BackgroundXMLSent(e.Argument, worker, e)

Since I am not interested in cancelation or progress the BackgrounXMLSent
routine just looks like:

Function BackgroundXMLSent(ByVal arguments As XmlSentArguments, ByVal
worker As BackgroundWorker, ByVal e As DoWorkEventArgs) As String
Return XMLSent(arguments.TransactionId, arguments.OrderId)
End Function

I have verified in the debugger that the routine XMLSent is returning so
BackgroundXMLSent is returning. The problem is the the event
RunWorkerCompleted does not get fired and the component always shows IsBusy
as True. Any ideas as to why this event is not firing and why the component
is always busy after the first call?

Thank you.

Kevin
 
G

Guest

It has been a long time but I think this was the solution. Basically I needed
to flush the queue before I started work so my call now looks like:

While searchThread.IsBusy
' Keep UI messages moving, so the form remains
' responsive during the asynchronous operation.
Application.DoEvents()
End While
searchThread.RunWorkerAsync(arguments)

I think this solve my problem anyway it works now like this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top