|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
AppDomain.DoCallBack, méthode
Espace de noms : System
Assembly : mscorlib (dans mscorlib.dll)
Paramètres
- callBackDelegate
- Type : System.CrossAppDomainDelegate
Délégué qui spécifie une méthode à appeler.
Implémentations
_AppDomain.DoCallBack(CrossAppDomainDelegate)| Exception | Condition |
|---|---|
| ArgumentNullException |
static string greetings = "PONG!"; public static void Main() { AppDomain otherDomain = AppDomain.CreateDomain("otherDomain"); greetings = "PING!"; MyCallBack(); otherDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack)); // Output: // PING! from defaultDomain // PONG! from otherDomain } static public void MyCallBack() { string name = AppDomain.CurrentDomain.FriendlyName; if (name == AppDomain.CurrentDomain.SetupInformation.ApplicationName) { name = "defaultDomain"; } Console.WriteLine(greetings + " from " + name); }
[Serializable] public class PingPong { private string greetings = "PING!"; public static void Main() { AppDomain otherDomain = AppDomain.CreateDomain("otherDomain"); PingPong pp = new PingPong(); pp.MyCallBack(); pp.greetings = "PONG!"; otherDomain.DoCallBack(new CrossAppDomainDelegate(pp.MyCallBack)); // Output: // PING! from defaultDomain // PONG! from otherDomain } public void MyCallBack() { string name = AppDomain.CurrentDomain.FriendlyName; if (name == AppDomain.CurrentDomain.SetupInformation.ApplicationName) { name = "defaultDomain"; } Console.WriteLine(greetings + " from " + name); } }
public class PingPong : MarshalByRefObject { private string greetings = "PING!"; public static void Main() { AppDomain otherDomain = AppDomain.CreateDomain("otherDomain"); PingPong pp = new PingPong(); pp.MyCallBack(); pp.greetings = "PONG!"; otherDomain.DoCallBack(new CrossAppDomainDelegate(pp.MyCallBack)); // Output: // PING! from defaultDomain // PONG! from defaultDomain } // Callback will always execute within defaultDomain due to inheritance from // MarshalByRefObject public void MyCallBack() { string name = AppDomain.CurrentDomain.FriendlyName; if (name == AppDomain.CurrentDomain.SetupInformation.ApplicationName) { name = "defaultDomain"; } Console.WriteLine(greetings + " from " + name); } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.