Book a Demo

Author Topic: Multithreaded Plugin  (Read 3429 times)

clicht

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Multithreaded Plugin
« on: September 01, 2011, 05:07:56 pm »
Is it possible to use the Automatin Interface (C#) within threads?

I know the AI is COM based and I know in COM several threading model exists.
Which of them is possible to use with EA?

Uses enybody of you the AI in a multithreaded enviroment, or in a enviroment which uses the BackgroundWorker?

shaunf

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Multithreaded Plugin
« Reply #1 on: September 07, 2011, 02:30:50 am »
I have lots of multithreaded plugins using
ThreadStart ts = new ThreadStart(The_method_calling);
Thread thread = new Thread(ts);
thread.start();

I have had no problems with threads in my plugins.

clicht

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Multithreaded Plugin
« Reply #2 on: September 08, 2011, 12:02:25 am »
Answer of the Support to my question:
Accessing Enterprise Architect's automation interface via multiple concurrent threads can cause issues and is not officially supported at this time.


But I think multithreading is possible, but only in the correct ApartmendState.
It is important that the thread is running in the STA mode.
This could be done by following:
Code: [Select]
thread.SetApartmentState(ApartmentState.STA);
This is also the reason why the BackgroundWorker is not possible to use. The System.Component.BackgroudWorker uses the thread pool for starting threads and this threads always runs in the ApartmentState.MTA mode.