Created
May 17, 2015 00:58
-
-
Save ChrisBriggsy/c94dee8f716f86cb5a38 to your computer and use it in GitHub Desktop.
How to Consume SignalR in Windows 10 IoT Core Insider Preview : Step 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNet.SignalR.Client; | |
using PropertyChanged; | |
using System; | |
using Windows.UI.Core; | |
namespace SignalRPiExample | |
{ | |
[ImplementPropertyChanged] | |
internal class MainViewModel | |
{ | |
private readonly CoreDispatcher _dispatcher; | |
public MainViewModel() | |
{ | |
_dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; | |
var connection = new HubConnection("http://internetuptime.azurewebsites.net/signalr"); | |
var hubProxy = connection.CreateHubProxy("UptimeHub"); | |
hubProxy.On<string>("internetUpTime", UpdateTime); | |
connection.Start(); | |
} | |
public string Uptime { get; set; } | |
private async void UpdateTime(string s) | |
{ | |
await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => Uptime = s); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment