Second WebBrowser control with SignalR freezes javascript

风流意气都作罢 提交于 2020-06-16 20:33:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!