I have read this question Is this a proper way of calling synchronous methods asynchronously? which is similar to my question, but not quite the same.
I have a method
Private Sub SendEmail(strFromAddress As String, strFromName As String, strSubject As String, strBody As String, strToAddress As String, strAttachment As String)
that is used for sending e-mail messages from within my program. However, to avoid a slight delay to the user, I have created an asynchronous method
Public Sub AsyncSendEmail(state As Object)
which basically calls SendEmail()
. I am invoking AsyncSendEmail()
like so:
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf AsyncSendEmail), params)
I am wondering if this is a correct way of passing off a synchronous method call into an asynchronous method so that it doesn't hold up the UI.