473,414 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

e.error in RunWorkerCompleted

If I have something like below, and I catch an error in DoWork, how do
I then get e.Error in RunWorkerCompleted to populate ?
Private Sub bg_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles _downloadWorker.DoWork
Try
e.Result = SomeLongRunningTask
Catch ex As Exception
e.Result = ex
End Try
End Sub

Private Sub bg_RunWorkerCompleted(ByVal sender As Object, ByVal e
As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
_downloadWorker.RunWorkerCompleted

If e.Error IsNot Nothing Then
MsgBox(e.Error.Message)
Else
If e.Cancelled Then
MsgBox("Cancelled")
Else
MsgBox("Done")
End If
End If
End Sub
Feb 29 '08 #1
1 2566
On Feb 29, 10:49*am, DrLargePants <drlargepa...@gmail.comwrote:
If I have something like below, and I catch an error in DoWork, how do
I then get e.Error in RunWorkerCompleted to populate ?

* * Private Sub bg_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles _downloadWorker.DoWork
* * * * Try
* * * * * * e.Result = SomeLongRunningTask
* * * * Catch ex As Exception
* * * * * * e.Result = ex
* * * * End Try
* * End Sub

* * Private Sub bg_RunWorkerCompleted(ByVal sender As Object, ByVal e
As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
_downloadWorker.RunWorkerCompleted

* * * * If e.Error IsNot Nothing Then
* * * * * * MsgBox(e.Error.Message)
* * * * Else
* * * * * * If e.Cancelled Then
* * * * * * * * MsgBox("Cancelled")
* * * * * * Else
* * * * * * * * MsgBox("Done")
* * * * * * End If
* * * * End If
* * End Sub
What error did you get? It may be related to your code execution.
Mar 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
3
by: nt8jbwu02 | last post by:
I am trying to use the example at: http://msdn2.microsoft.com/en-us/library/ms171728(d=ide).aspx to update a control in a thread safe maner. The article shows a couple of ways to do so and...
1
by: VAADADMIN | last post by:
I have a small app that I am working with to create LDIF files from text files. I have a pictureBox that has an animated GIF that will appear on the form when the LDIF are being created. The...
3
by: =?Utf-8?B?d2lsa29rb3N0ZW4=?= | last post by:
Dear all, I have the following question: I want to populate a datagridview after my BackGroundWorker has finished. I thought i could use the RunWorkerCompleted event to update my datagridview...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.