2007-11-30 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / tests / stackframes-async.2.cs
1 using System;
2 using System.Net;
3 using System.Diagnostics;
4
5 namespace stacktracetest
6 {
7         class MainClass
8         {
9                 static int frame_count = 0;
10                 public static int Main(string[] args)
11                 {
12                         AsyncCallback cback = new AsyncCallback(ResolveCallback);
13                         IAsyncResult res = Dns.BeginGetHostEntry("localhost", cback, null);
14                         System.Threading.Thread.Sleep(2000);
15                         /*
16                          * seems to be broken
17                         while (!res.IsCompleted) {
18                                 System.Threading.Thread.Sleep(20);
19                         };
20                         IPHostEntry ip = Dns.EndGetHostEntry (res);
21                         Console.WriteLine (ip);*/
22                         if (frame_count >= 1)
23                                 return 0;
24                         return 1;
25                 }
26                 
27                 public static void ResolveCallback(IAsyncResult ar)
28                 {
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());
35                     }
36                     Console.WriteLine("ResolveCallback() complete");
37                 }
38         }
39 }