InvalidOperationException in EnumerableDataSource.

Mar 8, 2011 at 9:48 AM
Edited Mar 9, 2011 at 6:20 AM

In my chart application I store Times and values in a param variable where contents of this params ( both time and values gets ) added dynamically by a separate thread.

My code look like this.....

        public void AddParameter(Param paramr)
                   //param.GetTimes() returns List<DateTime>
                   EnumerableDataSource<DateTime> xSource = param.GetTimes().AsDataSource();
                   xSource .SetXMapping(x => dateAxis.ConvertToDouble(x));

                   //param.GetValues() returns List<double>
                   EnumerableDataSource<double>  ySource  = param.GetValues().AsDataSource();
                   ySource.SetYMapping(y => y);

                    CompositeDataSource ds = new CompositeDataSource(xSource , ySource);
                   plotter.AddLineGraph(ds, 2, param.Name);

Data (both time and value) are getting added to the 'param' from outside this class dynamically.
The problem I am facing is I get an error "InvalidOperationException" which states that "Enumeration has either not started or has already finished."

Can anyone please suggest me where it went wrong? Thanks for your time.

Mar 9, 2011 at 6:28 AM

If possible Debug the plotter.AddLineGraph(ds, 2, param.Name);

There must be some out of range operation done on the Enumerable data type.

Mar 10, 2011 at 4:33 AM

Thanks Parvez for your comment. Yes, it was crashing from 'DynamicDataDisplay.dll'. It was crashing from the method 'public void GetCurrent(ref Point p)' inside 'EnumerablePointEnumerator'.

The method look like this....

        public void GetCurrent(ref Point p) {
            if (enumerator.MoveNext())   // I have added this condition to avoid the crash.
                dataSource.FillPoint((T)enumerator.Current, ref p);


Now its not crashing, but not bringing me the correct result....