The problem I ran into is the closing JS import tag itself, which stopped all the JS on the page running ...
For other users having the same problem, here is my working example on a server that displays data to all clients without any prompts from the client:
JavaScript:
$(function () {
HTML:
<h2 id="lblQuestion" runat="server">Please wait for a question...</h2>
Hub:
[HubName("chat")] public class Chat : Hub { public void Send(string message) {
Calling customers:
private void DoIt() { int i = 0; while (true) { var hubContext = GlobalHost.ConnectionManager.GetHubContext<Chat>(); hubContext.Clients.addMessage("Doing it... " + i); i++; Thread.Sleep(500); } }
Threaded DoIt () call:
var thread = new Thread(new ThreadStart(DoIt)); thread.SetApartmentState(ApartmentState.STA); thread.Start();
source share