3
我正在测试将运行在Azure Web角色中的SignalR应用程序。我有一个后台处理线程,在WebRole的OnStart中创建。WebRole中的SignalR IHubContext任务
当我尝试使用IHubContext发送组消息时,它失败并且没有错误 - 在集线器客户端中永远不会收到消息。从Global.asax内部创建的相同代码将正常运行。
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Microsoft.WindowsAzure
Imports Microsoft.WindowsAzure.Diagnostics
Imports Microsoft.WindowsAzure.ServiceRuntime
Imports Microsoft.AspNet.SignalR
Imports System.Threading.Tasks
Public Class WebRole
Inherits RoleEntryPoint
Public Overrides Function OnStart() As Boolean
Task.Factory.StartNew(Sub() AsyncTaskTest())
Return MyBase.OnStart()
End Function
Private Sub AsyncTaskTest()
Do
Threading.Thread.Sleep(10000)
Dim Context As IHubContext = GlobalHost.ConnectionManager.GetHubContext(Of Testub)()
Context.Clients.Group("testgroup").Message("This is a delayed message from the WebRole thread.")
Loop
End Sub
End Class
应该以这种方式使用IHubContext吗?这是否算作一个单独的程序集,并且需要使用HubConnection? 如果我不能使用IHubContext,我会恢复在Global.asax中使用这个,并保持Web应用程序的活着。
谢谢,丹尼尔
包含过程布局的体系结构在http://blogs.msdn.com/b/kwill/archive/2011/05/05/windows-azure-role-architecture.aspx –