1

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?

MojoDK
  • 4,237
  • 9
  • 40
  • 75

1 Answers1

0

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

Community
  • 1
  • 1
Benoit Patra
  • 4,164
  • 5
  • 26
  • 51