Poznámka:
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
Spustí funkci v zadané doméně aplikace.
Syntaxe
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 ]
);
Parametry
appdomainId
Doména aplikace, ve které se má funkce volat.
voidFunc
Ukazatel na void funkci, která přebírá parametry N (0 <= N <= 15).
nonvoidFunc
Ukazatel na nefunkcivoid , která přebírá parametry N (0 <= N <= 15).
arg1... argN
Nula až 15 parametrů, které se mají předat do voidFunc nebo nonvoidFunc v jiné doméně appdomain.
Návratová hodnota
Výsledek spuštění voidFunc nebo nonvoidFunc v zadané doméně aplikace.
Poznámky
Argumenty funkce předané call_in_appdomain nesmí být typy CLR.
Příklad
// 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 );
}
Výstup
default appdomain: msl_call_in_appdomain.exe
in appDomain1: First Domain
default appdomain id = 1
appDomain1 id = 2
Požadavky
Hlavičkový soubor<msclr\appdomain.h>
Obor názvů msclr