One thing I don’t understand with sending Async emails from ASP.NET page is when we call SendAsync it should be executed on a separate thread so our page can continue its execution flow and finish its response no matter how long the sending will take.
-
How then we can call method on the same page using
SendCompletedEventHandler? The page object might not exist by that time and in this forum there are examples that people doing that. -
My expectation was that I can have separate class which might have static method which I will execute on
SendCompletedEventHandlerand this way we can report possible errors.
However when I’m raising exception in there the exception comes as part of Page Response. So for me it looks as SendAsync works on the same thread, page waites for it to be executed and comes back with information on any errors raised by it.
Is it how it should be? So what is meaning of the Async then?
Completely confused… Can anyone help?
UPDATE: Found a post which helped me a lot HERE IS THE LINK
Because the handler is static, it doesn’t require the page object to still exist because it doesn’t use or depend on object state. When the callbackhandler needs to be called, the method can be invoked with no fear that the original object doesn’t exist.