c# - Async Controller Action Re-Called after one minute -
i have action on mvc3 async controller processes csv files, async part of follows:
[handleerror] [noasynctimeout] public void uploadasync(int jobid) { var timestamp = datetime.now; log.debug("uploadasync " + timestamp); var job = _fileuploadservice.getjob(jobid); log.debug("asyncmanager.outstandingoperations.increment " + timestamp); asyncmanager.outstandingoperations.increment(); var task = task<job>.factory.startnew(() => { thread.sleep(90000); }); task.continuewith(t => { try { asyncmanager.parameters["results"] = getjobresultdetails(jobid); } //no "catch" block. "task" takes care of us. { asyncmanager.outstandingoperations.decrement(); } }); }
and completed counterpart is:
public jsonresult uploadcompleted(int jobid) { log.debug("uploadcompleted"); try { return asyncmanager.parameters.containskey("results") ? json(asyncmanager.parameters["results"], jsonrequestbehavior.allowget) : json("", jsonrequestbehavior.allowget); } catch (exception ex) { exceptionhelper.logerror(ex, log, "message"); return json(""); } }
this works fine when processjob(job) task takes less minute. after minute, same task kicked off again on separate thread, processing same job 1 running.
is there obvious missing around timeout settings either async controller methods or tasks might cause behaviour?
edit-
i swapped call process job thread.sleep minute , half , when looked in log can see uploadasync has still been called twice nothing code processjob executes.
it worth noting happens when deployed integration server , not locally.
could there iis setting needs upping accomodate longer process time?
edit -
uploadasync called ajax:
$(document).ready(function () { $("#jobidtoprocess").text(@model.jobidtoprocess); var jobid = $("#jobidtoprocess").text(); if (jobid.charat(0)) { process(jobid); } }); function process(jobid) { alert("process called"); $.ajax({ type: "get", url: makeurl('~@string.format("/{0}/{1}", "fileupload", "upload")' + "/" + jobid), contenttype: "application/json; charset=utf-8", datatype: "json", beforesend: function(xhr) { $(window).bind('beforeunload', function() { xhr.abort(); }); }, traditional: true, success: function (data) { var uploadresults = $.parsejson(data); var completeddate = formatdate(uploadresults[0].completeddate); $("#completeddate" + jobid).html(completeddate); } }); }