AppDomain.DoCallBack 메서드
지정한 대리자에서 식별한 다른 응용 프로그램 도메인에 있는 코드를 실행합니다.
네임스페이스: System
어셈블리: mscorlib(mscorlib.dll)
구문
‘선언
Public Sub DoCallBack ( _
callBackDelegate As CrossAppDomainDelegate _
)
‘사용 방법
Dim instance As AppDomain
Dim callBackDelegate As CrossAppDomainDelegate
instance.DoCallBack(callBackDelegate)
public void DoCallBack (
CrossAppDomainDelegate callBackDelegate
)
public:
virtual void DoCallBack (
CrossAppDomainDelegate^ callBackDelegate
) sealed
public final void DoCallBack (
CrossAppDomainDelegate callBackDelegate
)
public final function DoCallBack (
callBackDelegate : CrossAppDomainDelegate
)
매개 변수
- callBackDelegate
호출할 메서드를 지정하는 대리자입니다.
설명
callBackDelegate에서는 값으로 마샬링한 MarshalByRefObject 또는 ContextBoundObject를 지정할 수 있습니다.
예제
다음 샘플에서는 정적 DoCallBack 메서드를 사용하는 방법에 대해 설명합니다.
Public Module PingPong
Private greetings As String = "PONG!"
Sub Main()
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
greetings = "PING!"
MyCallBack()
otherDomain.DoCallBack(AddressOf MyCallBack)
' Output:
' PING! from default domain
' PONG! from otherDomain
End Sub 'Main
Sub MyCallBack()
Dim name As String = AppDomain.CurrentDomain.FriendlyName
Console.WriteLine(greetings + " from " + name)
End Sub 'MyCallBack
End Module 'PingPong
static string greetings = "PONG!";
public static void Main() {
AppDomain currentDomain = AppDomain.CurrentDomain;
AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
greetings = "PING!";
MyCallBack();
otherDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack));
// Output:
// PING! from default domain
// PONG! from otherDomain
}
static public void MyCallBack() {
string name = AppDomain.CurrentDomain.FriendlyName;
Console.WriteLine(greetings + " from " + name);
}
public ref class PingPong
{
private:
static String^ greetings = "PONG!";
public:
static void MyCallBack()
{
String^ name = AppDomain::CurrentDomain->FriendlyName;
Console::WriteLine( "{0} from {1}", greetings, name );
}
static void Ping()
{
AppDomain^ currentDomain = AppDomain::CurrentDomain;
AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
greetings = "PING!";
MyCallBack();
otherDomain->DoCallBack( gcnew CrossAppDomainDelegate( MyCallBack ) );
// Output:
// PING! from default domain
// PONG! from otherDomain
}
};
int main()
{
PingPong::Ping();
}
private static String greetings = "PONG!";
public static void main(String[] args)
{
AppDomain currentDomain = AppDomain.get_CurrentDomain();
AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
greetings = "PING!";
MyCallBack();
otherDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack));
// Output:
// PING! from default domain
// PONG! from otherDomain
} //main
public static void MyCallBack()
{
String name = AppDomain.get_CurrentDomain().get_FriendlyName();
Console.WriteLine(greetings + " from " + name);
} //MyCallBack
다음 샘플에서는 값으로 DoCallBack 메서드를 사용하는 방법에 대해 설명합니다.
<Serializable> _
Public Class PingPong
Private greetings As String = "PING!"
Public Shared Sub Main()
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
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 otherDomain
End Sub 'Main
Public Sub MyCallBack()
Dim name As String = AppDomain.CurrentDomain.FriendlyName
Console.WriteLine(greetings + " from " + name)
End Sub 'MyCallBack
End Class 'PingPong
[Serializable]
public class PingPong {
private string greetings = "PING!";
public static void Main() {
AppDomain currentDomain = AppDomain.CurrentDomain;
AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
PingPong pp = new PingPong();
pp.MyCallBack();
pp.greetings = "PONG!";
otherDomain.DoCallBack(new CrossAppDomainDelegate(pp.MyCallBack));
// Output:
// PING! from default domain
// PONG! from otherDomain
}
public void MyCallBack() {
string name = AppDomain.CurrentDomain.FriendlyName;
Console.WriteLine(greetings + " from " + name);
}
}
[Serializable]
public ref class PingPong
{
private:
String^ greetings;
public:
PingPong()
{
greetings = "PING!";
}
void MyCallBack()
{
String^ name = AppDomain::CurrentDomain->FriendlyName;
Console::WriteLine( "{0} from {1}", greetings, name );
}
static void Ping()
{
AppDomain^ currentDomain = AppDomain::CurrentDomain;
AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
PingPong^ pp = gcnew PingPong;
pp->MyCallBack();
pp->greetings = "PONG!";
otherDomain->DoCallBack( gcnew CrossAppDomainDelegate( pp, &PingPong::MyCallBack ) );
// Output:
// PING! from default domain
// PONG! from otherDomain
}
};
int main()
{
PingPong::Ping();
}
/** @attribute Serializable()
*/
public class PingPong
{
private String greetings = "PING!";
public static void main(String[] args)
{
AppDomain currentDomain = AppDomain.get_CurrentDomain();
AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
PingPong pp = new PingPong();
pp.MyCallBack();
pp.greetings = "PONG!";
otherDomain.DoCallBack(new CrossAppDomainDelegate(pp.MyCallBack));
// Output:
// PING! from default domain
// PONG! from otherDomain
} //main
public void MyCallBack()
{
String name = AppDomain.get_CurrentDomain().get_FriendlyName();
Console.WriteLine(greetings + " from " + name);
} //MyCallBack
} //PingPong
다음 샘플에서는 참조로 DoCallBack 메서드를 사용하는 방법에 대해 설명합니다.
Public Class PingPong
Inherits MarshalByRefObject
Private greetings As String = "PING!"
Public Shared Sub Main()
Dim currentDomain As AppDomain = AppDomain.CurrentDomain
Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
Dim pp As New PingPong()
otherDomain.DoCallBack(AddressOf pp.MyCallBack)
pp.MyCallBack()
' Output:
' PING! from default domain
' PONG! from default domain
End Sub 'Main
Public Sub MyCallBack()
Dim name As String = AppDomain.CurrentDomain.FriendlyName
Console.WriteLine((greetings + " from " + name))
greetings = "PONG!"
End Sub 'MyCallBack
End Class 'PingPong
public class PingPong : MarshalByRefObject {
private string greetings = "PING!";
public static void Main() {
AppDomain currentDomain = AppDomain.CurrentDomain;
AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
PingPong pp = new PingPong();
otherDomain.DoCallBack(new CrossAppDomainDelegate(pp.MyCallBack));
pp.MyCallBack();
// Output:
// PING! from default domain
// PONG! from default domain
}
public void MyCallBack() {
string name = AppDomain.CurrentDomain.FriendlyName;
Console.WriteLine(greetings + " from " + name);
greetings = "PONG!";
}
}
public ref class PingPong: public MarshalByRefObject
{
private:
String^ greetings;
public:
PingPong()
{
greetings = "PING!";
}
void MyCallBack()
{
String^ name = AppDomain::CurrentDomain->FriendlyName;
Console::WriteLine( "{0} from {1}", greetings, name );
greetings = "PONG!";
}
static void Ping()
{
AppDomain^ currentDomain = AppDomain::CurrentDomain;
AppDomain^ otherDomain = AppDomain::CreateDomain( "otherDomain" );
PingPong^ pp = gcnew PingPong;
otherDomain->DoCallBack( gcnew CrossAppDomainDelegate( pp, &PingPong::MyCallBack ) );
pp->MyCallBack();
// Output:
// PING! from default domain
// PONG! from default domain
}
};
int main()
{
PingPong::Ping();
}
public class PingPong extends MarshalByRefObject
{
private String greetings = "PING!";
public static void main(String[] args)
{
AppDomain currentDomain = AppDomain.get_CurrentDomain();
AppDomain otherDomain = AppDomain.CreateDomain("otherDomain");
PingPong pp = new PingPong();
otherDomain.DoCallBack(new CrossAppDomainDelegate(pp.MyCallBack));
pp.MyCallBack();
// Output:
// PING! from default domain
// PONG! from default domain
} //main
public void MyCallBack()
{
String name = AppDomain.get_CurrentDomain().get_FriendlyName();
Console.WriteLine(greetings + " from " + name);
greetings = "PONG!";
} //MyCallBack
} //PingPong
플랫폼
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원