天天看點

await和async在C#一般處理程式(ashx)中的使用

public class hello : HttpTaskAsyncHandler, IReadOnlySessionState
    {

       
        public IFetchServise fetch { get; set; }


        public override async Task ProcessRequestAsync(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            var name = await fetch.RandomFortuneAsync();
            context.Response.Write(name);
        }

       

    
    }