title: How can I subscribe to a SignalR On event?
body: <p>I try to implement some SignalR calls to my WP 8.1 app, but I have some problem with the On method. I can connect to the server and I can send data to the server via signalr with the Invoke method. And I can receive data from the server with the next command: <br>
  </p>
  
  <pre><code>proxy.Subscribe("newTransaction").Received += newTransactionMethod;
  async void newTransactionMethod(IList&lt;Newtonsoft.Json.Linq.JToken&gt; obj)
  {
      await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt; { UpdateOutput2(obj[0]); });
  }
  
  void UpdateOutput2(dynamic data)
  {
      if (data != null)
      {
          NewTransaction nt = JsonConvert.DeserializeObject&lt;NewTransaction&gt;(data.ToString());
          Output2.Text = "From: " + nt.fromName + " , To: " + nt.toName + " , Amount: " + nt.amount;
      }
  }
  </code></pre>
  
  <p>But I would like to use the On method, not the Subscribe, because that is recommended and easier to use. My problem is when I try to use On method it's not working properly: I don't get any data from the server. Likely I cannot use it. <br>
  What I tried: <br></p>
  
  <pre><code>proxy.On&lt;string&gt;("newTransaction", data =&gt;
  {
      Output2.Text = data;
  });
  </code></pre>
  
  <p>Okay, I don't use the JsonConvert in this, but I can serialize it after I get the data.<br>
  Can anyone help me to solve my problem?</p>
  
  <p><strong>EDIT:</strong><br>
  Here is the full code, maybe it will help to investigate the problem.<br></p>
  
  <pre><code>public sealed partial class SignalrPage : Page
  {
      HubConnection connection;
      IHubProxy proxy;
  
      public SignalrPage()
      {
          this.InitializeComponent();
  
          this.NavigationCacheMode = NavigationCacheMode.Required;
  
          SignalR1();
      }
  
      protected override void OnNavigatedTo(NavigationEventArgs e)
      {
      }
  
      public async void SignalR1()
      {
          try
          {
              connection = new HubConnection("https://***");
              proxy = connection.CreateHubProxy("***Hub");
  
              await connection.Start(new WebSocketTransport());
  
              if (connection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected)
                  Output.Text = "Connected";
  
              var s = await proxy.Invoke&lt;LoginData&gt;("RegisterDevice", new LoginData()
              {
                  UserName = "***",
                  Password = "***",
                  DeviceId = "***",
                  DeviceType = 10
              });
              Output.Text = s.DeviceRegistered.ToString();
  
              //If I uncomment the next line and comment the proxy.On method is it working. But in this case not.
              //proxy.Subscribe("newTransaction").Received += newTransactionMethod;
  
              proxy.On&lt;string&gt;("newTransaction", data =&gt;
              {
                  Output2.Text = data;
              });
  
              Output3.Text = "It should be subscribed to newTransaction";
          }
          catch (Exception e)
          {
              Output.Text = e.ToString();
          }
      }
  
      async void newTransactionMethod(IList&lt;Newtonsoft.Json.Linq.JToken&gt; obj)
      {
          await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =&gt; { UpdateOutput2(obj[0]); });
      }
  
      void UpdateOutput2(dynamic data)
      {
          if (data != null)
          {
              NewTransaction nt = JsonConvert.DeserializeObject&lt;NewTransaction&gt;(data.ToString());
              Output2.Text = "From: " + nt.fromName + " , To: " + nt.toName + " , Amount: " + nt.amount;
          }
      }
  
  }
  </code></pre>