call_in_appdomain-Funktion
Führt eine Funktion in einer angegebenen Anwendung aus Standard.
Syntax
template <typename ArgType1, ...typename ArgTypeN>
void call_in_appdomain(
DWORD appdomainId,
void (*voidFunc)(ArgType1, ...ArgTypeN) [ ,
ArgType1 arg1,
...
ArgTypeN argN ]
);
template <typename RetType, typename ArgType1, ...typename ArgTypeN>
RetType call_in_appdomain(
DWORD appdomainId,
RetType (*nonvoidFunc)(ArgType1, ...ArgTypeN) [ ,
ArgType1 arg1,
...
ArgTypeN argN ]
);
Parameter
appdo Standard Id
Die Appdo Standard in der die Funktion aufgerufen werden soll.
voidFunc
Zeiger auf eine void
Funktion, die N-Parameter verwendet (0 <= N <= 15).
nonvoidFunc
Zeiger auf eine Nicht-Funktionvoid
, die N-Parameter verwendet (0 <= N <= 15).
arg1... argN
Null bis 15 Parameter, die an voidFunc
oder nonvoidFunc
in der anderen Appdo übergeben werden sollen Standard.
Rückgabewert
Das Ergebnis der Ausführung voidFunc
oder nonvoidFunc
in der angegebenen Anwendung Standard.
Hinweise
Die Argumente der an die Funktion übergebenen call_in_appdomain
Funktion dürfen keine CLR-Typen sein.
Beispiel
// msl_call_in_appdomain.cpp
// compile with: /clr
// Defines two functions: one takes a parameter and returns nothing,
// the other takes no parameters and returns an int. Calls both
// functions in the default appdomain and in a newly-created
// application domain using call_in_appdomain.
#include <msclr\appdomain.h>
using namespace System;
using namespace msclr;
void PrintCurrentDomainName( char* format )
{
String^ s = gcnew String(format);
Console::WriteLine( s, AppDomain::CurrentDomain->FriendlyName );
}
int GetDomainId()
{
return AppDomain::CurrentDomain->Id;
}
int main()
{
AppDomain^ appDomain1 = AppDomain::CreateDomain( "First Domain" );
call_in_appdomain( AppDomain::CurrentDomain->Id,
&PrintCurrentDomainName,
(char*)"default appdomain: {0}" );
call_in_appdomain( appDomain1->Id,
&PrintCurrentDomainName,
(char*)"in appDomain1: {0}" );
int id;
id = call_in_appdomain( AppDomain::CurrentDomain->Id, &GetDomainId );
Console::WriteLine( "default appdomain id = {0}", id );
id = call_in_appdomain( appDomain1->Id, &GetDomainId );
Console::WriteLine( "appDomain1 id = {0}", id );
}
Ausgabe
default appdomain: msl_call_in_appdomain.exe
in appDomain1: First Domain
default appdomain id = 1
appDomain1 id = 2
Anforderungen
Headerdatei<msclr\appdo Standard.h>
Namespace msclr
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Tickets als Feedbackmechanismus für Inhalte auslaufen lassen und es durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unter:Einreichen und Feedback anzeigen für