如何实现"没有等待"控制器要求的API? [英] How to implement "no wait" controller call for an API?
本文介绍了如何实现"没有等待"控制器要求的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组MVC3控制器方法,我从不需要返回任何数据我的JavaScript客户端称其。这纯粹是作进一步处理的小数据集的一种方式推动。每个控制器调用可以从任何地方为100ms采取1000MS排队事务,并没有数据/状态将被返回给客户端。
我只想API调用返回给客户端马上同时处理在后台发生的。
任何指针是AP preciated。
解决方案
公众的ActionResult AsyncAction()
{
VAR MyThread的=新主题(ThreadFunction);
MyThread.Start(); 返回视图(AsyncView);
}无效ThreadFunction()
{
。
。
// code的API调用等..
。
。
}
I have a set of MVC3 controller methods that i call from my JavaScript clients that do not require returning any data. It's purely one way push of tiny data-set for further processing. Each controller call can take anywhere from 100ms to 1000ms to queue up the transaction and no data/status will be returned back to the client.
I just want the API call to return to the client right away while the processing happens in the background.
Any pointers are appreciated.
解决方案
public ActionResult AsyncAction()
{
var MyThread = new Thread(ThreadFunction);
MyThread.Start();
return View("AsyncView");
}
void ThreadFunction()
{
.
.
//Code for API call etc...
.
.
}
这篇关于如何实现"没有等待"控制器要求的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文