IHttpAsyncHandler.EndProcessRequest not being called

S

Steve Wright

Hi All,

This is my first time using this interface, so I am sure I am just missing
something stupid. When my Http Handler gets called, the Begin runs and the
delegate runs, but the EndProcessRequest never runs and the page hangs
forever. Any idea why?

Public Class MyAsyncWebHandler
Implements IHttpAsyncHandler
Implements IReadOnlySessionState

Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
' not called
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return True
End Get
End Property

' Define the private Async method Delegate
Private Delegate Sub AsyncProcessRequest(ByVal context As HttpContext)

Public Function BeginProcessRequest( _
ByVal context As HttpContext, ByVal cb As AsyncCallback,
ByVal state As Object) _
As IAsyncResult Implements
IHttpAsyncHandler.BeginProcessRequest

Dim dlgt As New AsyncProcessRequest(AddressOf DoMyStuff)
Return dlgt.BeginInvoke(context, Nothing, Nothing)
End Function

Public Sub EndProcessRequest(ByVal ar As IAsyncResult) Implements
IHttpAsyncHandler.EndProcessRequest
Dim dlgt As AsyncProcessRequest = DirectCast(DirectCast(ar,
AsyncResult).AsyncDelegate, AsyncProcessRequest)
dlgt.EndInvoke(ar)
End Sub

Public Sub DoMyStuff(ByVal context As HttpContext)
Threading.Thread.Sleep(3000)
End Sub

End Class

Thanks,
 
B

bruce barker

is your async code async? is it calling SetCompleted()?


-- bruce (sqlwork.com)
 
S

Steve Wright

Thanks, Bruce.

I found that my problem was that I forgot to pass the callback when I did
the begin.

This:
Return dlgt.BeginInvoke(context, Nothing, Nothing)

should have been this:
Return dlgt.BeginInvoke(context, cb, Nothing)

When would I call SetComplete()? I am not familiar with that.

Thanks for your help,
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top