问题
In Outlook I have this code...
_connection = New HubConnection(Me._url)
_connection.Credentials = CredentialCache.DefaultCredentials
_hub = _connection.CreateHubProxy(Me._hubName)
_hub.On(Of String)("NewMessage", Function(message)
Dim f As New TestForm
f.Show()
Return ""
End Function)
_connection.Start()
But showing my form "TestForm" crashes since its in the main thread and SignalR is on another thread.
Any idea how I can make it work?
回答1:
Your best attempt would be to use a dedicated thread to do your SignalR jobs and get back on the main STA thread for accessing Outlook Object Model or displaying forms/WPF components.
This how you can "continue" your work on the main thread: Hooked events Outlook VSTO continuing job on main Thread
来源:https://stackoverflow.com/questions/35057480/signalr-outlook-add-in-and-multithread-exception