public static void GetContext(System.Net.HttpListener listener, Action <Exception, System.Net.HttpListenerContext> callback)
{
try
{
listener.BeginGetContext((result) =>
{
try
{
var context = listener.EndGetContext(result);
Loop.Post(() =>
{
callback(null, context);
});
}
catch (Exception exception)
{
Loop.Post(() =>
{
callback(exception, null);
});
}
}, null);
}
catch (Exception exception)
{
callback(exception, null);
}
}