R6025 pure virtual function call

家住魔仙堡 提交于 2019-12-04 21:03:32

Here's how I "fixed" the issue by making it fail less often ... there is now an initial delay of 200ms and the delay doubles every iteration of the loop. (Am still looking for a real solution)

    public bool GetValue(TimeSpan timeout, out object value, params object[] args) {

        value = null;
        var server = GetRtdServer();
        var topicId = GetTopicId();

        var sw = Stopwatch.StartNew();
        var delay = 200;

        try {
            server.ConnectData(topicId, args, true);
            while (sw.Elapsed < timeout) {
                Thread.Sleep(delay);
                delay *= 2;
                var alive = server.Heartbeat();
                if (alive != 1) {
                    // TODO: What should be done here?
                    return false;
                }
                var refresh = server.RefreshData(1);
                if (refresh.Length > 0) {
                    if (refresh[0, 0].ToString() == topicId.ToString()) {
                        value = refresh[1, 0];
                        return true;
                    }
                }
            }
        } catch (Exception ex) {
            // TODO: Log exception
            return false;
        } finally {
            server.DisconnectData(topicId);
            sw.Stop();
        }
        return false;
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!