本文整理匯總了VB.NET中System.ServiceModel.SessionMode枚舉的典型用法代碼示例。如果您正苦於以下問題:VB.NET SessionMode枚舉的具體用法?VB.NET SessionMode怎麽用?VB.NET SessionMode使用的例子?那麽, 這裏精選的枚舉代碼示例或許可以為您提供幫助。
在下文中一共展示了SessionMode枚舉的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Hello
' 導入命名空間
Imports System.Collections.Generic
Imports System.ServiceModel
Imports System.Threading
Namespace Microsoft.WCF.Documentation
<ServiceContract(Name:="SampleDuplexHello", Namespace:="http://microsoft.wcf.documentation", _
CallbackContract:=GetType(IHelloCallbackContract), SessionMode:=SessionMode.Required)> _
Public Interface IDuplexHello
<OperationContract(IsOneWay:=True)> _
Sub Hello(ByVal greeting As String)
End Interface
Public Interface IHelloCallbackContract
<OperationContract(IsOneWay := True)> _
Sub Reply(ByVal responseToGreeting As String)
End Interface
<ServiceBehaviorAttribute(InstanceContextMode:=InstanceContextMode.PerSession)> _
Public Class DuplexHello
Implements IDuplexHello
Public Sub New()
Console.WriteLine("Service object created: " & Me.GetHashCode().ToString())
End Sub
Protected Overrides Sub Finalize()
Console.WriteLine("Service object destroyed: " & Me.GetHashCode().ToString())
End Sub
Public Sub Hello(ByVal greeting As String) Implements IDuplexHello.Hello
Console.WriteLine("Caller sent: " & greeting)
Console.WriteLine("Session ID: " & OperationContext.Current.SessionId)
Console.WriteLine("Waiting two seconds before returning call.")
' Put a slight delay to demonstrate asynchronous behavior on client.
Thread.Sleep(2000)
Dim callerProxy As IHelloCallbackContract = OperationContext.Current.GetCallbackChannel(Of IHelloCallbackContract)()
Dim response = "Service object " & Me.GetHashCode().ToString() & " received: " & greeting
Console.WriteLine("Sending back: " & response)
callerProxy.Reply(response)
End Sub
End Class
End Namespace