First off, what language are you using?
It really depends on what extent you want to do the threading. In ALE, I create classes(.dlls) that do all my work for me. I then create a background thread for that class and wait for it to finish. It's not the most efficent but it works.
You can't, however, call multiple instances of, let's say, cell editor...even if you are calling a different partition. I have tried that before, even creating a new object of that class, and it still would not let me run two different instance to speed up the process.
Here is an example of how I do it in VB.
Create a class, then create an instance of that class.
Dim trdWork as thread
trdWork = new Thread(Address of clWork.ThingIWantTodo)
trdWork.isbackground = true
From here the thread is complete and you can put code in to pull the data from that class isntances
Dim sResults as string = clWork.sResults
Here is a great link that would help with treading:
We are using c#.
That is, it starts in VBScript and goes like this:
- (drag the VBScript onto the Expedition PCB document)
- set DllLoader=createobject("fsc_mgcentry.fsc_mgcentry") ' this is our .NET dll loader.
- set AddOnObject=DllLoader.LoadAssembly("...\xxx.dll") ' this loads the (properly attributed c#-)assembly from a network share and creates the default object.
- (attaching events and other stuff)
Now, "methodcall()" displays the Gui, I click around, press the "runActions"-button and then Expedition API calls happen. Only, the Gui should display progress, react to clicks and generally be alive.
Currently we do a very cumbersome procedure of the Gui sitting on a separate thread and funneling back predefined calls to the main thread. This is what I'd like to get rid of. In fact, I'd like to use the Windows Forms background worker control for the API stuff.
In addition, of course, we do have machines with 8 CPUs and it'd be great if we could utilize them for CPU intensive stuff like mask engine operations. For this it's necessary to know how the API reacts to several API calls happen all at once. Like, I "pick" on each quarter of a PCB and process them independently. Then overlapping Components will be queried from two threads.
As for your example, does it work with more than one worker thread too?
All API calls must be done on the main UI thread, you will get an exception if you attempt to call a method from a worker thread.
In your main thread, build up a data structure with information gathered through the API, and create a thread to do the time-consuming work with those data structures.
If you need to make any changes to the document object, your addin can queue up the necessary data structures, and process those in the next OnIdle event.
That's a pity but thanks a lot for confirming it.
Lots of Greetings!