Skip to content

Instantly share code, notes, and snippets.

Created October 22, 2014 21:39
Show Gist options
  • Save anonymous/72d0d6f5ac04babab7b6 to your computer and use it in GitHub Desktop.
Save anonymous/72d0d6f5ac04babab7b6 to your computer and use it in GitHub Desktop.
Async test
public class Principal : IPrincipal
{
public IIdentity Identity
{
get { return null; }
}
public bool IsInRole(string role)
{
throw new NotImplementedException();
}
}
public class Startup
{
public void Configuration(IAppBuilder app)
{
var random = new Random();
int requestId = 0;
app.Run(async ctx =>
{
var id = Interlocked.Increment(ref requestId);
HttpContext.Current.User = new Principal();
var user = HttpContext.Current.User;
await Task.Delay(random.Next(100, 10000));
Debug.Assert(object.ReferenceEquals(user, HttpContext.Current.User));
Debug.WriteLine("Request {0} done waiting", id);
await Task.FromResult<string>(null);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment