Skip to content

Instantly share code, notes, and snippets.

@ChrisBriggsy
Created May 17, 2015 00:58
Show Gist options
  • Save ChrisBriggsy/c94dee8f716f86cb5a38 to your computer and use it in GitHub Desktop.
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
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