Closed fiyazbinhasan closed 6 years ago
Hi Fiyaz!
The issue is that your trigger handler is async
hronous and at the moment this library does not support that.
Also, I'm curious why you're creating a new Task
inside your async
hronous handler?
You get the error sometimes because the context is disposed after it is used, but your handler may still be trying to run in some other thread. Since your handler makes use of the e.Context
object, it may or may not be disposed by the time your handler code runs. Basically this is thread-unsafe.
Some simple fixes are:
async
hronous handler code, create a new context instance and use that one
e.Context
object which keeps it as one transactionBill
objects to your context, call the SaveChangesAsync
so the entire transaction is run outside your calling thread.Cheers.
I think i get the idea. Sorry I left the Task.Factory.StartNew
in the code. Actually I was trying different things to get rid of that problem. But now I know that the handlers can't be asynchronous
! Thanks @NickStrupat đź‘Ť
I'm getting this error where it's telling me that my context is already disposed so I cant access it anymore. I've this trigger implemented in my
Order.cs
class, which basically updates the order status,Following is the
PaymentStatusChangeNotifierAsync
code,The
await PaymentStatusChangeNotifierAsync(e);
occasionally gives me the following exception.Is there any problems with my trigger implementation?