public delegate string CaptureHandler(string ip);
public class CaptureService
{
public static string CapturePicture(string ip)
{
Thread.Sleep(3000);
Console.WriteLine("work done part one");
return ip.ToString();
}
}
static void Main(string[] args)
{
//Thread t = new Thread(new ParameterizedThreadStart(functionA));
CaptureHandler handler = new CaptureHandler(CaptureService.CapturePicture);
IAsyncResult result = handler.BeginInvoke("192.168.0.109", new AsyncCallback(SaveDb), handler);
Console.WriteLine("main work continue");
Console.ReadKey();
}
private static void SaveDb(IAsyncResult ar)
{
if (ar.IsCompleted)
{
Console.WriteLine("work done part two");
var handler = ar.AsyncState as CaptureHandler;
var result = handler.EndInvoke(ar);
Console.WriteLine(result);
}
Console.WriteLine("ok");
}