本文整理匯總了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