[netcore] Ongoing work. (#13391)
[mono-project.git] / mono / tests / appdomain-async-invoke.cs
blob3e7894c06c78af34a529a63556042bddb8cd4da1
1 using System;
2 using System.Threading;
3 using System.Runtime.Remoting;
5 public class Test : MarshalByRefObject {
6 delegate int GetIntDelegate ();
8 static void async_callback (IAsyncResult ar)
10 Console.WriteLine ("Async Callback in domain " + AppDomain.CurrentDomain + " " + ar.AsyncState);
13 ~Test () {
14 Console.WriteLine ("in test destructor");
15 GetIntDelegate del = new GetIntDelegate (getInt);
16 AsyncCallback ac = new AsyncCallback (async_callback);
17 if (del.BeginInvoke (ac, "bla") == null) {
18 Console.WriteLine ("async result is null");
19 Environment.Exit (1);
23 public int getInt () {
24 Console.WriteLine ("getInt in " + AppDomain.CurrentDomain);
25 return 123;
29 public class main {
30 public static int Main (string [] args) {
31 AppDomain domain = AppDomain.CreateDomain ("newdomain");
32 int i;
34 for (i = 0; i < 200; ++i) {
35 domain.CreateInstanceAndUnwrap (typeof (Test).Assembly.FullName, typeof (Test).FullName);
38 Console.WriteLine ("unloading");
39 AppDomain.Unload (domain);
40 Console.WriteLine ("unloaded");
42 GC.Collect ();
43 GC.WaitForPendingFinalizers ();
45 Console.WriteLine ("done");
47 return 0;