Note that there are some explanatory texts on larger screens.

plurals
  1. POSignalR client in asp.net
    primarykey
    data
    text
    <p>I created a server hub in an asp.net application like below</p> <pre><code>public class Calc : Hub { public void CalculateSomething(int a, int b) { // start working in a new thread var task = Task.Factory.StartNew(() =&gt; DoCalculate(a, b)); // attach a continuation task to notify // the client when the work is done task.ContinueWith(t =&gt; { System.Threading.Thread.Sleep(2000); Clients.addMessage(t.Result); Caller.notifyCalculateResult(t.Result); System.Threading.Thread.Sleep(2000); Caller.notifyCalculateResult("Completed"); Clients.addMessage("Completed"); }); } private int DoCalculate(int p1, int p2) { // do some slow work on the input, // e.g. call webservice or I/O. int result = p1 + p2; //int result = DoSlowWork(p1, p2); return result; } } </code></pre> <p>Now in another asp.net application I created a client using SiganlR client. But it's not working correctly. I am looking to get data from server as it pushes to client</p> <pre><code>using System.Threading.Tasks; using SignalR; using SignalR.Client; using SignalR.Client.Hubs; namespace WebApplication2 { public partial class _Default : Page { protected void Page_Load(object sender, EventArgs e) { // Connect to the service var hubConnection = new HubConnection("http://localhost:3119/"); // Create a proxy to the chat service var chat = hubConnection.CreateProxy("Calc"); // Print the message when it comes in chat.On("addMessage", message =&gt;Print(message)); // Start the connection hubConnection.Start().Wait(); // Send a message to the server chat.Invoke("CalculateSomething", 1, 2).Wait(); } private async void Print(object message) { Response.Write(message); } } } </code></pre> <p>The console client application works fine. The main problem is with asp.net beacause it fails to the handle call back from server.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload