c# - timer lifetime for a IIS web app -
i need add retry logic web request if write db failed. i'd try 2 more times delay of 500ms before quitting. there no requirement block user response during retry. question is, once response made, timer still alive complete retries or killed after response?
why not make use of async/await. make things little easier:
public someresult handlewebrequest() { startthing(); //not awaited - fire-and-forget //return response } public async void startthing() { //await task.yield(); //return control call site , finish asynchronously for(var numtries = 0; numtries < 3; numtries++) { if(trysomethingthatmightnotwork)break; await task.delay(5000); } }
Comments
Post a Comment