【发布时间】:2016-11-07 03:20:45
【问题描述】:
在我的一个 WCF 服务(无状态)中,我想通过 SignalR 发送一条消息。因为服务是无状态的,并且集线器在另一台机器上,所以我连接到 SignalR,发送消息,然后断开连接。
proxy.Connect().Wait();
proxy.SendMessageToUsers(receiverUserNames, message).Wait();
proxy.Disconnect();
有时会出现InvalidOperationExceptions(在收到调用结果之前连接已断开)。
我从这篇文章 (C# SignalR Exception - Connection started reconnecting before invocation result was received) 了解到 .Wait 不是一个好主意。但我想我需要等待 Connect 和 SendMessage 完成,然后再断开连接。
那么,我还能做什么?
最好的问候, 斯蒂芬
【问题讨论】: