3 using System.Diagnostics;
5 namespace stacktracetest
9 static int frame_count = 0;
10 public static int Main(string[] args)
12 AsyncCallback cback = new AsyncCallback(ResolveCallback);
13 IAsyncResult res = Dns.BeginGetHostEntry("localhost", cback, null);
14 System.Threading.Thread.Sleep(2000);
17 while (!res.IsCompleted) {
18 System.Threading.Thread.Sleep(20);
20 IPHostEntry ip = Dns.EndGetHostEntry (res);
21 Console.WriteLine (ip);*/
27 public static void ResolveCallback(IAsyncResult ar)
29 Console.WriteLine("ResolveCallback()");
30 StackTrace st = new StackTrace();
31 frame_count = st.FrameCount;
32 for(int i = 0; i < st.FrameCount; i++) {
33 StackFrame sf = st.GetFrame(i);
34 Console.WriteLine("method: {0}", sf.GetMethod());
36 Console.WriteLine("ResolveCallback() complete");