How to implement “no wait” controller call for an API?

旧街凉风 提交于 2019-12-12 02:14:39

问题


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.


回答1:


public ActionResult AsyncAction()
{
    var MyThread = new Thread(ThreadFunction);
    MyThread.Start();

    return View("AsyncView");
}

void ThreadFunction()
{
    .
    .
    //Code for API call etc...
    .
    .
}


来源:https://stackoverflow.com/questions/16348653/how-to-implement-no-wait-controller-call-for-an-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!