Im facing a general question where I cannot find a good example to try this for myself. Google doesn't help either.
Imagine this structure:
MailMessage mail = new MailMessage(sender, receiver); using(SmtpClient client = new SmtpClient()) { client.Host ... client.Port ... mail.subject ... mail.body ... client.SendAsync(mail); }
What to do if the server is slow and takes some time to receive mail. Is it possible that SmtpClient is before the operation? Will it be destroyed or broken in any way?
Is there a general answer for this? The servers here are too fast, they donβt know how to do a survey.
If you are thinking of canceling BackgroundWorker , it always finishes the current operation. Maybe the same thing here, or maybe not ...
c # asynchronous using-statement dispose
C4u
source share