本文整理匯總了VB.NET中System.Web.DefaultHttpHandler類的典型用法代碼示例。如果您正苦於以下問題:VB.NET DefaultHttpHandler類的具體用法?VB.NET DefaultHttpHandler怎麽用?VB.NET DefaultHttpHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DefaultHttpHandler類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: defaulthttpexampleVB
Public Class defaulthttpexampleVB
Inherits DefaultHttpHandler
Private _context As HttpContext
Public Overrides Function BeginProcessRequest _
(ByVal context As HttpContext, _
ByVal callback As AsyncCallback, _
ByVal state As Object) As IAsyncResult
Dim ar As New AsyncResultSample(callback, state)
_context = context
Return (ar)
End Function
Public Overrides Sub EndProcessRequest(ByVal result As IAsyncResult)
_context.Response.Write("EndProcessRequest called.")
End Sub
' This method should not be called asynchronously.
Public Overrides Sub ProcessRequest(ByVal context As HttpContext)
Throw New InvalidOperationException _
("Asynchronous processing failed.")
End Sub
' Enables pooling when set to true
Public Overrides ReadOnly Property IsReusable() As Boolean
Get
Return True
End Get
End Property
End Class
' Tracks state between the begin and end calls.
Class AsyncResultSample
Implements IAsyncResult
Private callback As AsyncCallback = Nothing
Private _asyncState As Object
Private _isCompleted As Boolean
Friend Sub New(ByVal cb As AsyncCallback, ByVal state As Object)
Me.callback = cb
_asyncState = state
_isCompleted = False
End Sub
Public ReadOnly Property AsyncState() As Object _
Implements IAsyncResult.AsyncState
Get
Return _asyncState
End Get
End Property
Public ReadOnly Property CompletedSynchronously() _
As Boolean Implements IAsyncResult.CompletedSynchronously
Get
Return False
End Get
End Property
Public ReadOnly Property AsyncWaitHandle() _
As WaitHandle Implements IAsyncResult.AsyncWaitHandle
Get
Throw New InvalidOperationException _
("ASP.NET should not use this property .")
End Get
End Property
Public ReadOnly Property IsCompleted() _
As Boolean Implements IAsyncResult.IsCompleted
Get
Return IsCompleted
End Get
End Property
Friend Sub SetCompleted()
_isCompleted = True
If (callback <> Nothing) Then
callback(Me)
End If
End Sub
End Class