zoukankan      html  css  js  c++  java
  • 基于异步的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  on July 4, 2016.

  • 相关阅读:
    完美解决CTRL+空格不能切换中/英文输入法的问题
    【Delphi内联汇编学习1】Delphi与汇编
    替换bmp图片中的颜色 good
    将四个BYTE数值转换成IEEE754标准的浮点数(两种方法:用Addr函数取字节数字的首地址,或者用Absolute关键字)
    在delphi的exe文件中嵌入另外一个exe文件
    Qt中的串口编程之三
    使用MIDAS访问远程Access数据库
    QSqlDatabase的进一步封装(多线程支持+更加简单的操作)——同时支持MySQL, SQL Server和Sqlite
    Qt for Linux:环境搭建(CentOS 6.5 32位)——完全从零安装
    Qt for Windows:使用WinPcap开发高性能UDP服务器
  • 原文地址:https://www.cnblogs.com/micro-chen/p/5849588.html
Copyright © 2011-2022 走看看