What would you like to submit? (put an 'x' inside the bracket that applies)
[ ] question
[X ] bug report
[ ] feature request
I am using the NuGet package in VS 2019 version 3.8.0 with Deedle version 2.2.0 in NuGet. The following code causes an accessed from a thread other than the thread error:
var dailyReturnHistogram = HistogramBox
.Show(
ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll.ToArray()
).SetNumberOfBins(20);
System.Threading.Thread.Sleep(3000);
dailyReturnHistogram.Invoke(
new Action(() =>
{
dailyReturnHistogram.Size = new System.Drawing.Size(700, 500);
})
);
The full error is:
System.InvalidOperationException
HResult=0x80131509
Message=Cross-thread operation not valid: Control 'HistogramBox' accessed from a thread other than the thread it was created on.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.Invalidate(Boolean invalidateChildren)
at System.Windows.Forms.Control.Refresh()
at Accord.Controls.HistogramBox.SetNumberOfBins(Int32 number)
at ForeignExchangeRate.Chapter4BookExample.BookDataAnalyzer() in C:\Users\DDemland\source\repos\ForeignExchangeRate\ForeignExchangeRate\Chapter4BookExample.cs:line 59
at ForeignExchangeRate.Program.Main(String[] args) in C:\Users\DDemland\source\repos\ForeignExchangeRate\ForeignExchangeRate\Program.cs:line 17
This exception was originally thrown at this call stack:
[External Code]
ForeignExchangeRate.Chapter4BookExample.BookDataAnalyzer() in Chapter4BookExample.cs
ForeignExchangeRate.Program.Main(string[]) in Program.cs
If I comment out the call to SetNumberOfBins as in the following:
var dailyReturnHistogram = HistogramBox
.Show(
ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll.ToArray()
); //.SetNumberOfBins(20);
System.Threading.Thread.Sleep(3000);
dailyReturnHistogram.Invoke(
new Action(() =>
{
dailyReturnHistogram.Size = new System.Drawing.Size(700, 500);
})
);
The code does not error. What do I have to do to get this code to run?
What would you like to submit? (put an 'x' inside the bracket that applies)
I am using the NuGet package in VS 2019 version 3.8.0 with Deedle version 2.2.0 in NuGet. The following code causes an accessed from a thread other than the thread error:
var dailyReturnHistogram = HistogramBox .Show( ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll.ToArray() ).SetNumberOfBins(20);
System.Threading.Thread.Sleep(3000); dailyReturnHistogram.Invoke( new Action(() => { dailyReturnHistogram.Size = new System.Drawing.Size(700, 500); }) );
The full error is:
System.InvalidOperationException HResult=0x80131509 Message=Cross-thread operation not valid: Control 'HistogramBox' accessed from a thread other than the thread it was created on. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Control.Invalidate(Boolean invalidateChildren) at System.Windows.Forms.Control.Refresh() at Accord.Controls.HistogramBox.SetNumberOfBins(Int32 number) at ForeignExchangeRate.Chapter4BookExample.BookDataAnalyzer() in C:\Users\DDemland\source\repos\ForeignExchangeRate\ForeignExchangeRate\Chapter4BookExample.cs:line 59 at ForeignExchangeRate.Program.Main(String[] args) in C:\Users\DDemland\source\repos\ForeignExchangeRate\ForeignExchangeRate\Program.cs:line 17
This exception was originally thrown at this call stack: [External Code] ForeignExchangeRate.Chapter4BookExample.BookDataAnalyzer() in Chapter4BookExample.cs ForeignExchangeRate.Program.Main(string[]) in Program.cs
If I comment out the call to SetNumberOfBins as in the following:
var dailyReturnHistogram = HistogramBox .Show( ohlcDF.FillMissing(0.0)["DailyReturn"].ValuesAll.ToArray() ); //.SetNumberOfBins(20);
System.Threading.Thread.Sleep(3000); dailyReturnHistogram.Invoke( new Action(() => { dailyReturnHistogram.Size = new System.Drawing.Size(700, 500); }) );
The code does not error. What do I have to do to get this code to run?
Thank You,
David Demland