コード例 #1
0
        private void OnLoading()
        {
            try
            {
                while (!IsDisposed)
                {
                    var removingSeries = new List <CandleSeries>();

                    foreach (var info in _series.CachedValues)
                    {
                        if (info.IsStopping)
                        {
                            removingSeries.Add(info.Series);
                        }
                        else
                        {
                            var values = new List <TSourceValue>(100);

                            for (var i = 0; i < 100; i++)
                            {
                                if (!info.Reader.MoveNext())
                                {
                                    removingSeries.Add(info.Series);
                                    break;
                                }

                                values.Add(info.Reader.Current);
                            }

                            if (values.Count > 0)
                            {
                                NewSourceValues(info.Series, values);
                            }
                        }
                    }

                    if (removingSeries.Count > 0)
                    {
                        lock (_series.SyncRoot)
                            removingSeries.ForEach(s => _series.Remove(s));

                        removingSeries.ForEach(RaiseStopped);
                    }

                    lock (_series.SyncRoot)
                    {
                        if (_series.IsEmpty())
                        {
                            Monitor.Wait(_series.SyncRoot);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                RaiseError(ex);
                _series.CopyAndClear().ForEach(p => RaiseStopped(p.Key));
            }
        }
コード例 #2
0
        private void OnLoading()
        {
            try
            {
                while (!IsDisposed)
                {
                    var removingSeries = new List <CandleSeries>();

                    foreach (var info in _series.CachedValues)
                    {
                        if (info.IsStopping)
                        {
                            removingSeries.Add(info.Series);
                        }
                        else
                        {
                            if (info.Reader.MoveNext())
                            {
                                var candle = info.Reader.Current;

                                if (info.Series.CheckTime(candle.OpenTime))
                                {
                                    RaiseProcessing(info.Series, candle);
                                }
                            }
                            else
                            {
                                removingSeries.Add(info.Series);
                            }
                        }
                    }

                    if (removingSeries.Count > 0)
                    {
                        lock (_series.SyncRoot)
                            removingSeries.ForEach(s => _series.Remove(s));

                        removingSeries.ForEach(RaiseStopped);
                    }

                    lock (_series.SyncRoot)
                    {
                        if (_series.IsEmpty())
                        {
                            Monitor.Wait(_series.SyncRoot);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                RaiseError(ex);
                _series.CopyAndClear().ForEach(p => RaiseStopped(p.Key));
            }
        }