I am sort of new to threading in ASP.Net so hopefully you can shed some light on what I am doing wrong here.
Essentially I have an application that runs a pretty lengthy process in a seperate sub. I want to thread the sub so I simply changed the call to the long running sub from Call buildDoc() to:
Dim NewThread As New Thread(New ThreadStart(AddressOf buildDoc))
NewThread.Priority = ThreadPriority.Lowest
NewThread.Name = "CatalogBuild"
Seems like a good idea in theory as it does free up my UI to do other things, however it is obvious that the buildDoc subroutine is failing somewhere along the line (It programmatically instantiates a connection to a VPN and performs some transactions with our AS/400). The sub worked fine with the simple call but began failing after I threaded it. The problem is the process seems to die without throwing any of the exceptions that it used to so I can't tell what is going wrong.
I was told elsewhere that the only way to return exceptions thrown by threaded processes was to use delegates but I am unsure how that would help. Ideas? I have a top-level error handler setup in global.asax as such:
Private Sub Global_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error
Application("_ERROR") = Server.GetLastError()
Dim ex As Exception = Server.GetLastError()
If (Not ex Is Nothing) Then
Dim innerException As Exception = ex
' Change to locale of error page
' Get rid of the progressbar on error
Application("progress_" & Session.SessionID) = 100
Application("complete_" & Session.SessionID) = True
Perhaps the above handler is not taking into account the specific type of exception that threads produce and hence isn't tripping when the error occurs?
I will post the contents of the buildDoc() sub if need-be but it is quite lengthy. You can view what it looks like by checking out the last comment on this previous post: https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21933943.html
Any help would be thoroughly appeciated!