Create an instance AxTChart in my worker thread

TeeChart for ActiveX, COM and ASP
Post Reply
PS Soluções
Newbie
Newbie
Posts: 11
Joined: Fri Jun 06, 2008 12:00 am
Location: Brazil
Contact:

Create an instance AxTChart in my worker thread

Post by PS Soluções » Thu Jul 16, 2009 9:01 pm

I would like to create an instance o AxTChart inside my class (I'm working with C#), setup some plots, get an image. The problem is that this function is inside a method being executed in a worker thread and there is no Form associated with it.

When I do "new AxTChart()" I get an thread exception that says that I "cannot create an instance of the ActiveX control because the current segment is not in an STA (single-threaded apartment)".

What should I do?

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Create an instance AxTChart in my worker thread

Post by Marc » Mon Jul 20, 2009 9:22 am

Hello,

I don't have any example project setup to check this but it seems that the thread will probably need to be created as single thread.

eg.

Code: Select all

using System;
using System.Threading;
namespace testapp
{
   class Class1
   {
      static void Main(string[] args)
      {
       Thread.CurrentThread.ApartmentState = 
          ApartmentState.STA;
      }
   }
}
If that doesn't give you the results you require and you have a small sample application you can send us we'll take a look.

Regards,
Marc Meumann
Steema Support

Post Reply