当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET CallContext.FreeNamedDataSlot方法代码示例

本文整理汇总了VB.NET中System.Runtime.Remoting.Messaging.CallContext.FreeNamedDataSlot方法的典型用法代码示例。如果您正苦于以下问题:VB.NET CallContext.FreeNamedDataSlot方法的具体用法?VB.NET CallContext.FreeNamedDataSlot怎么用?VB.NET CallContext.FreeNamedDataSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Runtime.Remoting.Messaging.CallContext的用法示例。


在下文中一共展示了CallContext.FreeNamedDataSlot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: TcpChannel

' Register the channel.
Dim myChannel As New TcpChannel()
ChannelServices.RegisterChannel(myChannel)
RemotingConfiguration.RegisterActivatedClientType(GetType(HelloService), "Tcp://localhost:8082")


Dim myIdentity As New GenericIdentity("Bob")
Dim myPrincipal As New GenericPrincipal(myIdentity, New String() {"Level1"})
Dim myData As New MyLogicalCallContextData(myPrincipal)

' Set DataSlot with name parameter.
CallContext.SetData("test data", myData)

' Create a remote object.
Dim myService As New HelloService()
If myService Is Nothing Then
   Console.WriteLine("Cannot locate server.")
   return
End If

' Call the Remote methods.
Console.WriteLine("Remote method output is " + myService.HelloMethod("Microsoft"))

Dim myReturnData As MyLogicalCallContextData = _
                  CType(CallContext.GetData("test data"), MyLogicalCallContextData)

If myReturnData Is Nothing Then
   Console.WriteLine("Data is null.")
Else
   Console.WriteLine("Data is '{0}'", myReturnData.numOfAccesses)
End If 

' DataSlot with same Name Parameter which was Set is Freed.
CallContext.FreeNamedDataSlot("test data")
Dim myReturnData1 As MyLogicalCallContextData = _
                  CType(CallContext.GetData("test data"), MyLogicalCallContextData)

If myReturnData1 Is Nothing Then
   Console.WriteLine("FreeNamedDataSlot Successful for test data")
Else
   Console.WriteLine("FreeNamedDataSlot Failed  for test data")
End If
开发者ID:VB.NET开发者,项目名称:System.Runtime.Remoting.Messaging,代码行数:42,代码来源:CallContext.FreeNamedDataSlot


注:本文中的System.Runtime.Remoting.Messaging.CallContext.FreeNamedDataSlot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。