Are the SmtpClient.SendMailAsync methods Thread Safe?

后端 未结 2 670
傲寒
傲寒 2021-01-05 17:30

The SmtpClient Class states that instance members are not thread safe. This can be seen if concurrent calls are made to Send or SendAsync. Both methods will throw a Invali

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-05 17:56

    As a note (since I don't have enough points to comment), the traditional way to write an asynchronous operation was to use the Asynchronous Programming Model (APM), but today we typically use the Task-based Asynchronous Pattern (TAP) with its async/await keywords. And although it's not unusual to see TAP wrappers around APM methods, it's also possible to see APM wrappers around TAP methods.

提交回复
热议问题