本文整理汇总了VB.NET中System.AppDomain.DoCallBack方法的典型用法代码示例。如果您正苦于以下问题:VB.NET AppDomain.DoCallBack方法的具体用法?VB.NET AppDomain.DoCallBack怎么用?VB.NET AppDomain.DoCallBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.AppDomain
的用法示例。
在下文中一共展示了AppDomain.DoCallBack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: PingPong
Public Module PingPong
Private greetings As String = "PONG!"
Sub Main()
Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
greetings = "PING!"
MyCallBack()
otherDomain.DoCallBack(AddressOf MyCallBack)
' Output:
' PING! from defaultDomain
' PONG! from otherDomain
End Sub
Sub MyCallBack()
Dim name As String = AppDomain.CurrentDomain.FriendlyName
If name = AppDomain.CurrentDomain.SetupInformation.ApplicationName Then
name = "defaultDomain"
End If
Console.WriteLine(greetings + " from " + name)
End Sub
End Module 'PingPong
示例2: PingPong
<Serializable> _
Public Class PingPong
Private greetings As String = "PING!"
Public Shared Sub Main()
Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
Dim pp As New PingPong()
pp.MyCallBack()
pp.greetings = "PONG!"
otherDomain.DoCallBack(AddressOf pp.MyCallBack)
' Output:
' PING! from defaultDomain
' PONG! from otherDomain
End Sub
Public Sub MyCallBack()
Dim name As String = AppDomain.CurrentDomain.FriendlyName
If name = AppDomain.CurrentDomain.SetupInformation.ApplicationName Then
name = "defaultDomain"
End If
Console.WriteLine(greetings + " from " + name)
End Sub
End Class
示例3: PingPong
Public Class PingPong
Inherits MarshalByRefObject
Private greetings As String = "PING!"
Public Shared Sub Main()
Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
Dim pp As New PingPong()
pp.MyCallBack()
pp.greetings = "PONG!"
otherDomain.DoCallBack(AddressOf pp.MyCallBack)
' Output:
' PING! from default domain
' PONG! from default domain
End Sub
' Callback will always execute within defaultDomain due to inheritance from
' MarshalByRefObject
Public Sub MyCallBack()
Dim name As String = AppDomain.CurrentDomain.FriendlyName
If name = AppDomain.CurrentDomain.SetupInformation.ApplicationName Then
name = "defaultDomain"
End If
Console.WriteLine((greetings + " from " + name))
End Sub
End Class