As a rule to make all functions async all way down to avoid mixing sync code with async ones (which can deadlock) I marked my Cache callback method async as it have async code inside. Is it ok to do so? Or I have to call sync methods only.
asp.net
public static async void Expired (String key, object value, CacheItemRemovedReason removedReason)
{
if (removedReason != CacheItemRemovedReason.Removed)
{
Status retStatus=await processResultAsync(id)
}
return;
}
public async Task<ActionResult> check(xViewModel x)
{
....
//I want to process thisid after 18-19 minutes even
// on cases when I will not be able to get redirectcallback
HttpContext.Cache.Insert(x.id, payment_key, null, DateTime.Now.AddMinutes(19), Cache.NoSlidingExpiration,
CacheItemPriority.Default, new CacheItemRemovedCallback(Expired));
....
return Redirect("external url that will call my RedirectCallback");
}
public async Task<ActionResult> RedirectCallback(String id)
{
Status retStatus=await processResultAsync(id);
......
HttpContext.Cache.Remove(id);
.......
return View( retStatus);
}
Aucun commentaire:
Enregistrer un commentaire