System.Threading.Tasks ライブラリを使用して、100% 非同期で WCF サービス呼び出しを開始しようとしています。以下のコード例で HandleChange メソッドを呼び出すと、クライアント サービスの呼び出しが完了するまで待ってから次の行に進むように見えます。私はこのようなことをしたいのですが、「ショーを止める」のではなく、クライアントの呼び出しが完了する前に、これを呼び出すメソッドが次のコード行に移動することを意味します。私はこれに間違ってアプローチしている可能性があるので、誰かが私が間違っていること、またはここで行っていることをどのように達成できるかについての洞察を提供できれば、非常に感謝しています。
Imports System.Threading.Tasks
Public Class ChangeWrapper
Public Shared Sub HandleChange(ByVal orgEntity As MainObjectBase, ByVal newEntity As MainObjectBase)
Parallel.Invoke(Sub()
Using client As New EventQueueService.EventQueueClient
client.QueueDecision(orgEntity, newEntity)
End Using
End Sub)
End Sub
End Class
編集: SLaks Answer に基づいて変更した内容を反映するには
Imports System.Threading.Tasks
Public Class ChangeWrapper
Public Shared Sub HandleChange(ByVal orgEntity As MainObjectBase, ByVal newEntity As MainObjectBase)
Task.Factory.StartNew(Sub()
Using client As New EventQueueService.EventQueueClient
client.QueueDecision(orgEntity, newEntity)
End Using
End Sub)
End Sub
End Class