我已阅读此问题Is this a proper way of calling synchronous methods asynchronously?,这与我的问题类似,但不完全相同。
我有一个方法
Private Sub SendEmail(strFromAddress As String, strFromName As String, strSubject As String, strBody As String, strToAddress As String, strAttachment As String)
用于从我的程序中发送电子邮件。但是,为了避免对用户造成轻微延迟,我创建了一个异步方法
Public Sub AsyncSendEmail(state As Object)
基本上调用SendEmail()
。我这样调用AsyncSendEmail()
:
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf AsyncSendEmail), params)
我想知道这是否是将同步方法调用传递给异步方法的正确方法,以便它不会阻止UI。