具有多种功能的SignalR迭代 [英] SignalR iteration with multiple functions

查看:58
本文介绍了具有多种功能的SignalR迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以最近我一直在使用这个SignalR代码将我的javascript功能连接到实时数据库,

so recently I've been using this SignalR Code to connect my javascript function to a Realtime Database,

// Proxy created on the fly
        var data = $.connection.newHub;

        // Declare a function on the location hub so the server can invoke it
        data.client.displayStatus = function () {
            alert("Iteration!!");
            setTimeout(getData, 8000);
        };

        // Start the connection

        $.connection.hub.start()
            //connection started
            alert("connection started");
            getData();

    });

现在,如果我运行上面的代码,一切都运行顺利,没有任何问题,每8秒迭代一次。但是,每当我添加多个函数时,这样:

Now, If i run the code above, everything runs smoothly with no problems and iterates every 8 second. However, whenever i add multiple functions like so:

// Proxy created on the fly
        var data = $.connection.newHub;

        // Declare a function on the location hub so the server can invoke it
        data.client.displayStatus = function () {
            alert("Iteration!!");
            setTimeout(getData, 8000);
            setTimeout(getData2, 8000);
        };

        // Start the connection

        $.connection.hub.start()
            //connection started
            alert("connection started");
            getData();
            getData2();

    });




迭代将开始变得混乱并连续迭代4次并且乘以更快的速度乘以第二个导致我的项目滞后。我怎样才能解决这个问题?提前致谢。


The iteration will start to get messy and iterates 4 times in a row and multiply even faster by the second causing my project to lag. How can i fix this? Thanks in Advance.

推荐答案

Hi MVCNoob,

Hi MVCNoob,

此论坛正在讨论Visual Studio WPF / SL Designer,Visual Studio Guidance Automation Toolkit,开发人员文档和帮助系统以及Visual Studio编辑器。

我建议您最好将问题重新发布到以下论坛以获得更好的答案。感谢您的理解。

I suggest that you had better repost the issue to the following forum for a better answer. Thank you for your understanding.

https://forums.asp.net/

此致,

奥斯卡


这篇关于具有多种功能的SignalR迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆