33

Is SignalR suitable for windows desktop applications (winforms/wpf)?

What are the advantages and disadvantages using SignalR with windows desktop applications?

Are there any performance considerations?

I want to make real-time connections between server and a lot of clients. The connections will be constant.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Seçkin Durgay
  • 2,758
  • 4
  • 27
  • 36

4 Answers4

28

Is SignalR suitable for windows desktop applications (winforms/wpf)?

The answer from signalr.net is:

SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application.

(As stated correctly by others it can be self-hosted, so no need for IIS)

So the answer seems to be no. It is a server side API. But today is your lucky day, since the download of SignalR doesn't only reveal the server side API, but also a client side API called Microsoft.AspNet.SignalR.Client45 to use in your application. It works for WPF, WF or even console applications.

And even if it didn't, SignalR is just a wrapper around the WebSockets protocol, which is part of the HTTP protocol, which can be used on virtually any platform. The download also contains a sample for iOS and Xamarin for example.

What are the advantages and disadvantages using SignalR with windows desktop applications?

To have real-time notifications from and to the server.

Is there any performance problems?

That is a hard question to answer, since there is no reference point. Compared to what the performance is good or bad? Generally spoken, I don't think you have to worry to much about that. The API itself is fast, and it may prevent slow pull-requests you need to do else.

Community
  • 1
  • 1
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
13

It is absolutelly correct to consume SinglarR hub in any client application, WPF, windows phone, UWP, iOS, Android, including HTML. Microsoft has created client libraries on many platforms.

When it comes to hosting SignalR, then you can definitelly host you SingalR server (hub) in WPF application, but you need a reason:

The reason may be:

  • IIS is not available
  • You don't know in advance where the APP will be used. You just need to run an app, that will notify other apps
  • Performance - IIS adds some performance overhead.

By the way, SignalR and OWIN has been an inspiration for the new ASP.NET 5. You can now host your ASP.NET apps in WPF, console application or windows service app without IIS, or even on Linux.

http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Liero
  • 25,216
  • 29
  • 151
  • 297
5

In a setup with a server and many clients: If you need "push" notifications from the server to some clients then SignalR is good to use.

I do so with WPF clients.

DrKoch
  • 9,556
  • 2
  • 34
  • 43
1

When you build a website with signalr functionality you have a signalR server, where the site is hosted and a signalr client, the javascript client that runs in the web browser that browses the site.

From years immemorable, web browsers were (and still are)... well,... desktop applications...

So you have desktop applications (the web broswer) that use SignalR to connect to a web site (the web server).

So, not only is it correct to use signalR for desktop applications, but this is what it is meant for. I really don't know what would be the use of signalR if it wasn't to be used in a desktop application at some point, because, frankly, a user sits in front of a desktop (or a smart device), and doesn't exist "in the cloud" (unless you are Neo from Matrix). With signalR you have "real-time" reactions from the server presented in your desktop environment (a web browser or another desktop application, for instance an application that controls the lights in your home, or prints something in your printer).

Thanasis Ioannidis
  • 2,981
  • 1
  • 30
  • 50