Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- class Program
- {
- [DllImport("test.dll")]
- static extern void WireCallback(Action func); // This saves the func in unmanaged space.
- [DllImport("test.dll")]
- static extern void DoCallback(); // This calls the saved func.
- static Action callback;
- static void Main()
- {
- callback = () => { };
- WireCallback(callback);
- AppDomain ad = AppDomain.CreateDomain("foo");
- ad.DoCallBack(new CrossAppDomainDelegate(OtherDomainTest));
- }
- static void OtherDomainTest()
- {
- int appDomainId = AppDomain.CurrentDomain.Id;
- DoCallback();
- Console.WriteLine("appDomainId == AppDomain.CurrentDomain.Id = {0}", appDomainId == AppDomain.CurrentDomain.Id);
- Debug.Assert(appDomainId == AppDomain.CurrentDomain.Id);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement