SendAsync (async email) and event handlers / life cycle in ASP.NET?

One thing that I donโ€™t understand when sending Async emails from an ASP.NET page is that when we call SendAsync, it must be executed in a separate thread so that our page can continue the execution thread and complete its response no matter how long it takes to send accept.

  • How can we call a method on one page using SendCompletedEventHandler ? By then, the page object might not exist, and there are examples on this forum that people do this.

  • I expected that I could have a separate class that could have a static method that I would execute on the SendCompletedEventHandler , and that way we could report possible errors. However, when I raise an exception, the exception comes as part of the Response. Therefore, for me it looks like this: SendAsync works in one thread, on the waites page to execute it, and returns with information about any errors that occurred.

How should it be? So what does asink mean?

Totally confused ... Can anyone help?

UPDATE: Found a message that helped me a lot HERE LINE

+4
source share
1 answer

Since the handler is static, it does not require the page object to still exist, because it does not use or is independent of the state of the object. When you need to call a callbackhandler, you can call the method without fear that the source object does not exist.

0
source

Source: https://habr.com/ru/post/1402074/


All Articles