I’ve developed a twitter application in .Net MVC that auto tweets msgs on specified timings.
The core function of application basically contains a recursive function the post tweets and keep calling itself until a database field is set to false which it’ll check in the next run.
The problem is that when I run the application or function through url, the browser goes in the “waiting for response… ” mode while the function is running correctly in the background in a recursive loop for a specified time until browser returns a page not found error which is I think is the default time set in browsers that they stop connecting after a website doesn’t return response for a specified time and after this when browser stop connecting the function also stop executing.
What I want is to the let this function call itself recursively in the background but also return the control to the interface until I click the off button and change the status field in the database to false, something like multithreading?
So on the basic not, how I can let a function running in background and also return the control to the front interface.
Kindly help.
public ActionResult twitter_post(string msg)
{
bool status = //retrieve from database;
while(status==true){
//post Tweets;
twitter_post(msg);
}
return View();
}
You can do it by using jquery timer plugin, call the server side function by json until you get your required result.
this function will keep on calling your function after every 60 second. And when you get required out put then stop it by using