I want to create charts which shall be stored in a database. So the charts are not shown in a UI or something.
The chart is periodically created after a specific time span. Responsible for the chart creation is a new thread which runs in the background.
The problem I noticed is that the handle count increases even though I call Dispose() on the chart object.
Code: Select all
public void test()
{
for ( int i = 0; i < Int32.MaxValue; i++ )
{
Thread thread = new Thread( new ThreadStart( delegate()
{
// Lock the image creation because TeeChart seems to use GDI functions
// (in the ContourMapControls constructor) which are not thread-safe.
test();
} ) );
thread.Name = "Handle increase demo";
thread.Priority = ThreadPriority.BelowNormal;
thread.Start();
}
}
private void test1()
{
TChart tchart = new TChart();
try
{
}
finally
{
tchart.Dispose();
}
Thread.Sleep( 10 );
}
Do I use something wrong or is there a alternative?
I also attached a sample project.
Thanks.
SurveyBob