/
stackframes-async.2.cs
54 lines (48 loc) · 1.31 KB
/
stackframes-async.2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Net;
using System.Diagnostics;
class MainClass
{
static int frame_count = 0;
public static int Main(string[] args)
{
AsyncCallback cback = new AsyncCallback(ResolveCallback);
IAsyncResult res = Dns.BeginGetHostEntry("localhost", cback, null);
System.Threading.Thread.Sleep(2000);
/*
* seems to be broken
while (!res.IsCompleted) {
System.Threading.Thread.Sleep(20);
};
IPHostEntry ip = Dns.EndGetHostEntry (res);
Console.WriteLine (ip);*/
if (frame_count < 1)
return 1;
// A test for #444383
AppDomain.CreateDomain("1").CreateInstance(typeof (Class1).Assembly.GetName ().Name, "Class1");
return 0;
}
public static void ResolveCallback(IAsyncResult ar)
{
Console.WriteLine("ResolveCallback()");
StackTrace st = new StackTrace();
frame_count = st.FrameCount;
for(int i = 0; i < st.FrameCount; i++) {
StackFrame sf = st.GetFrame(i);
Console.WriteLine("method: {0}", sf.GetMethod());
}
Console.WriteLine("ResolveCallback() complete");
}
}
public class Class1
{
public Class1 () {
AppDomain.CreateDomain("2").CreateInstance(typeof (Class1).Assembly.GetName ().Name, "Class2");
}
}
public class Class2
{
public Class2 () {
new StackTrace(true);
}
}