fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
924 stars 196 forks source link

SetNumberOfBins causes accessed from a thread other than the thread error #512

Closed ddemland closed 3 years ago

ddemland commented 3 years ago

I am using the NuGet package in VS 2019 version 2.2.0 and I have tried various packages all the way back to version 1.1.5 with the same out come. The following code causes an accessed from a thread other than the thread:

// Time-series line chart of daily returns var dailyReturnLineChart = DataSeriesBox.Show( ohlcDF.RowKeys.Select(x => (double)x), ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll );

System.Threading.Thread.Sleep(3000); dailyReturnLineChart.Invoke( new Action(() => { dailyReturnLineChart.Size = new System.Drawing.Size(700, 500); }) );

var dailyReturnHistogram = HistogramBox .Show( ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll.ToArray() ).SetNumberOfBins(20); // This does not work, it throws an error

System.Threading.Thread.Sleep(3000); dailyReturnHistogram.Invoke( new Action(() => { dailyReturnHistogram.Size = new System.Drawing.Size(700, 500); }) );


If I comment out the SetNumberOfBin call as in the following code example:

var dailyReturnHistogram = HistogramBox .Show( ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll.ToArray() ); //.SetNumberOfBins(20); This does not work, it throws an error

System.Threading.Thread.Sleep(3000); dailyReturnHistogram.Invoke( new Action(() => { dailyReturnHistogram.Size = new System.Drawing.Size(700, 500); }) );

I do not get the error.

This code is from an example I am using to try to learn how to use Deedle and a second example has the same issue. Could someone explain how to correct the problem?

Thank You,

David Demland

zyzhu commented 3 years ago

I'm afraid this repro is not minimal enough to isolate the problem, as HistogramBox and SetNumberOfBins are not part of Deedle. Could you share more detailed error messages?

ddemland commented 3 years ago

Never mind these are part of Accord.net. I will have to work with them. My fault.