コード例 #1
0
        //private static Timer _timer2 =
        //    new Timer(CheckSubs, null, 1000, 1000);

        //private static void CheckSubs(object state)
        //{
        //    var brokenSubs = Level2List.Where(x => x.Level2Data.Count == 0).ToList();
        //    foreach (var sub in brokenSubs)
        //    {
        //        TXmlConnector.ConnectorSendCommand(
        //            ConnectorCommands.SubUnsubCommand("subscribe", "quotes", sub.Board, sub.Seccode));
        //    }
        //}
        private static void ClearSubs(object state)
        {
            var            windows = _dispatcher.Invoke(() => Application.Current.Windows);
            List <IAnchor> list    = new List <IAnchor>();

            foreach (Window window in windows)
            {
                var context = _dispatcher.Invoke(() => window.DataContext);
                if (context is IAnchor)
                {
                    list.Add((IAnchor)context);
                }
            }

            Level2Subscription[] arr = new Level2Subscription[Level2List.Count];
            Level2List.CopyTo(arr, 0);
            foreach (var level2Subscription in arr)
            {
                var sub = list.Count(c => c.Board == level2Subscription.Board &&
                                     c.Seccode == level2Subscription.Seccode);
                if (sub == 0)
                {
                    TXmlConnector.ConnectorSendCommand(
                        ConnectorCommands.SubUnsubCommand("unsubscribe", "quotes", level2Subscription.Board, level2Subscription.Seccode));
                    var subscription = level2Subscription;
                    Level2List.TryTake(out subscription);
                }
            }
        }
コード例 #2
0
        public static ObservableCollection <Level2Item> AddLevel2Subscribtion(string board, string seccode)
        {
            var subscription = Level2List.FirstOrDefault(x => x.Board == board && x.Seccode == seccode);

            if (subscription == null)
            {
                subscription = new Level2Subscription
                {
                    Board   = board,
                    Seccode = seccode
                };
                Level2List.Add(subscription);
                TXmlConnector.ConnectorSendCommand(
                    ConnectorCommands.SubUnsubCommand("subscribe", "quotes", subscription.Board, subscription.Seccode));
            }
            return(subscription.Level2Data);
        }