基于异步的MVC webAPI控制器

MVC – Task-based Asynchronous Pattern (TAP) – Async Controller and SessionLess Controller

In async programming, there are 3 different models for different scenarios :

  • Asynchronous Programming Model – APM
  • Task Based Asynchronous Programming Model – TAPM
  • Evented Asynchronous Programming Model – EAPM

We can use all models in .net framework. It provides related libraries in their own namespaces. The Task-based Asynchronous Pattern (TAP) is based on System.Threading.Tasks.Task and System.Threading.Tasks.Task<TResult> types in the System.Threading.Tasks namespaces.

When we’re developing web application, if we need to develop async applications on web side, we can use this libraries to reflect async behavior. For Instance, if we want to communicate external services or channels at the same time, we might use async controller to avoid operation blocks. When we’re reflecting this behavior in an application, We should think tasks in action level. I mean, surely according to our scenario, if we seperate all actions as different tasks, it can be more useful and manageble.

In .Net Framework MVC Applications, We can use Async Controllers and async actions. For instance please check code below :

And also, if you need to run multiple requests concurrently, use SessionLess controller :

AST

 

This entry was posted in .Net FrameworkASP.NetDesign PatternsMVCServer Side Web Programming,Web Programming and tagged asyncasynchronous operationscontrollermvc 5sessionlesstaptask based asynchronous pattern on July 4, 2016.

转载于:https://www.cnblogs.com/micro-chen/p/5849588.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值