Thread Safety in Utils.CalcColorBlend?
Posted: Mon Aug 23, 2010 9:18 am
Hi,
I've been having some threading issues that seem to be related to TeeChart. I'm getting the following exception when my code is executed (by ASP.NET IIS) in several simultaneous requests:
My own code indicates, as expected from the stacktrace, that this happens when I call new Bar(ch); (ch being my Chart-object).
Using Reflector, it seems to stem from the fact that the Utils-class maintains a static Bitmap instance for calculating default gradient colors using FillRect and GetPixel. So when two Bars are constructed simultaneously, they both attempt to retrieve Graphics-handles for the same Bitmap. This seems odd and unnecessary. I would expect the calculation to be a simple linear progression which can be handled by multiplication, which should be much more efficient as well.
Is there some way I can avoid the (unnecessary) calculation, as I'm using solid colors for my bars? Or are there plans to fix this bug?
My TeeChart.dll is listed as v. 4.0.2010.13051.
I've been having some threading issues that seem to be related to TeeChart. I'm getting the following exception when my code is executed (by ASP.NET IIS) in several simultaneous requests:
Code: Select all
System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.FromImage(Image image)
at Steema.TeeChart.Utils.CalcColorBlend(Color start, Color end, Int32 percentage)
at Steema.TeeChart.Styles.Series.ModifySeriesColors(Color color)
at Steema.TeeChart.Styles.CustomBar.ModifySeriesColors(Color color)
at Steema.TeeChart.Styles.Series.Added()
at Steema.TeeChart.Styles.SeriesCollection.Add(Series s)
at Steema.TeeChart.Styles.Series..ctor(Chart c)
at Steema.TeeChart.Styles.CustomBar..ctor(Chart c)
at Steema.TeeChart.Styles.Bar..ctor(Chart c)
Using Reflector, it seems to stem from the fact that the Utils-class maintains a static Bitmap instance for calculating default gradient colors using FillRect and GetPixel. So when two Bars are constructed simultaneously, they both attempt to retrieve Graphics-handles for the same Bitmap. This seems odd and unnecessary. I would expect the calculation to be a simple linear progression which can be handled by multiplication, which should be much more efficient as well.
Is there some way I can avoid the (unnecessary) calculation, as I'm using solid colors for my bars? Or are there plans to fix this bug?
My TeeChart.dll is listed as v. 4.0.2010.13051.