问题
In my WinForm application, I have a "main" .net WebBrowser control with the following JS:
var $hub;
$(function () {
$hub = $.connection.sendHub;
$.connection.hub.stateChanged(connectionStateChanged);
$.connection.hub.disconnected(function () {
setTimeout(function () {
$.connection.hub.start();
}, 10000);
});
$hub.client.broadcastMessage = function (action, argument, tag) {
// Do something
};
$.connection.hub.start({ waitForPageLoad: false }).done(function () {
});
function connectionStateChanged(state) {
var stateConversion = { 0: 'connecting', 1: 'connected', 2: 'reconnecting', 4: 'disconnected' };
console.log('SignalR state changed from: ' + stateConversion[state.oldState] + ' to: ' + stateConversion[state.newState]);
};
});
In a 2nd WebBrowser Control, I have exact the same code as above, but if I try to post some JSON back to the server, the page freezes. If I comment out the $.connection.hub.start... function in the 2nd WebBrowser control, my JSON post works perfectly.
Is it not possible to start a second hub?
I need to do something in the 2nd WebBrowser Control, that will update some stuff in the 1st WebBrowser Control.
来源:https://stackoverflow.com/questions/24247171/second-webbrowser-control-with-signalr-freezes-javascript