c# - How to handle exceptions from async method with using Enterprise Library? -


exceptioncallhandler default exception call handler in enterprise library, doesn't work async methods.

how should rewrite handler work async methods?

it code, doesn't work.

public imethodreturn invoke(imethodinvocation input, getnexthandlerdelegate getnext)         {             if (input == null)                 throw new argumentnullexception("input");             if (getnext == null)                 throw new argumentnullexception("getnext");             imethodreturn methodreturn = getnext()(input, getnext);              methodinfo methodinfo = input.methodbase methodinfo;             bool istask = methodinfo != null && typeof(task).isassignablefrom(methodinfo.returntype);             task continuetask = null;              if (istask)             {                 task task = methodreturn.returnvalue task;                 if (task != null)                 {                     continuetask = task.continuewith((t) =>                     {                         if (t.exception != null)                         {                             methodreturn.exception = t.exception.flatten().innerexception;                         }                     }, taskscheduler.fromcurrentsynchronizationcontext());                 }             }              if (continuetask != null)             {                 continuetask.wait();             }              handlemethodreturnexception(methodreturn, input);               return methodreturn;         } 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -