简体   繁体   English

我可以在Winform c#app中使用SignalR吗?

[英]Can I use SignalR in my Winform c# app?

I have a web service being polled every few seconds in my winform c# app. 我在winform c#app中每隔几秒钟就会调查一次Web服务。 It checks for messages and gets them from my server and/or it relays messages from my desktop app to my server. 它检查消息并从我的服务器获取消息和/或它将消息从我的桌面应用程序中继到我的服务器。

The web service is being invoke in an infinite loop which the User can stop and start at the click of a button. Web服务正在无限循环中调用,用户可以通过单击按钮来停止和启动。 When the polling is on the memory goes up and stays up (which I guess I expected using infinite loop). 当轮询开启时,内存会上升并保持上升(我猜我使用无限循环)。 If there was way for my server to notify my client that a message is available then I assume I can get rid of my infinite loop. 如果我的服务器有办法通知我的客户端有消息可用,那么我认为我可以摆脱我的无限循环。 I was looking at different architectures and I came across SignalR but it seems more geared for asp.net. 我正在寻找不同的架构,我遇到了SignalR,但它似乎更适合asp.net。 Is that the case? 是这样的吗? Or can it be modified to work in my scenario here? 或者它可以修改为在我的场景中工作吗?

thanks 谢谢

Using SignalR as a client (or server) requires win8+ to get websockets. 使用SignalR作为客户端(或服务器)需要win8 +来获取websockets。 That should be something you are very aware of before using it. 在使用它之前,这应该是你非常清楚的。 I learned the hard way ;) See support here http://www.asp.net/signalr/overview/signalr-1x/getting-started/supported-platforms 我学到了很难的方法;)请看这里的支持http://www.asp.net/signalr/overview/signalr-1x/getting-started/supported-platforms

See this answer about boosting asmx/WCF to become a push service in 2 lines of code. 请参阅此答案,了解如何将asmx / WCF提升为2行代码中的推送服务。 Push Data from a WCF Service to Website 将数据从WCF服务推送到网站

There is a .NET client for SignalR, also you can self host SignalR using Owin SignalR有一个.NET客户端,你也可以使用Owin自己主持SignalR

Install package 安装包

Microsoft.AspNet.SignalR.Client

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM