Question WCF service crashed when asynchronus task throw exception

Shrek_1985

New member
Joined
Jul 25, 2011
Messages
1
Programming Experience
3-5
Hello.
I have WCF service.
I have one function, my function connect to other service and Download data. Data is very big, because my function download data part by part. But for download part-by-part, my WCF service client timeout must be very big, and client must wait very long :(. I resolve this task but I have one problem.

Private Delegate Sub AsyncDelegate()

Private mObject As New Object

Private mFinished As Boolean = True
Public Function Finished() As Boolean
Return mFinished
End Function

Public Sub AsynchronousDownload()
Dim asyncelegate As New AsyncDelegate(AddressOf Download)

SyncLock mObject
mFinished = False
asyncelegate.BeginInvoke(AddressOf AsynchronousEndDownload, "")
End SyncLock
End Sub

Private Sub Download()

End Sub

Private Sub AsynchronousEndDownload(ByVal ar As IAsyncResult)
Dim result As AsyncResult = CType(ar, AsyncResult)
Dim asyncelegate As AsyncDelegate = CType(result.AsyncDelegate, AsyncDelegate)

asyncelegate.EndInvoke(ar)
End Sub

'Data contract part
Public Sub DownloadData() _
Implements IMyService.DownloadData

AsynchronousDownload()
End Sub

Public Function DownloadFinished() As Boolean _
Implements IMyService.DownloadFinished

Return Finished()
End Function

'Service Call from client dll.
Sub DownloadData()
Proxy.DownloadData()

While Not Proxy.DownloadFinished()
Threading.Thread.Sleep(5000)
End While
End Sub

I resolve the problem, and my client timeout is 1 minute. But when in Download() function throw exception my WCF service is crashed. My WCF service catch all exception and write in log file, but when throw exception in Asynchronous task(Download function), excheption can't catched.
Help me please...
 
Back
Top