I have a rather complex and strange problem happening when working with IOperation and AsyncDo[AndWaitForFinish]
Before trying to understand what's really going bad, can you please shed some light on why would AsyncDoAndWaitForFinish raise "Wrong Thread" ?
Here's what I have - and I'll try to make it as simple as possible:
- I have my class "MyOp" implementing IOperation
- I have a list of MyOp instances
- I'm using Inst.AsyncDo to "execute" MyOp's (called for each my op instance in the list)
- Inside the MyOp.Do() method:
== OpenDocumentFromFile to get a CoreDocument::IPXC_Document
== do some stuff with CoreDocument (like Set OpenActions and alike)
== placing headers footers (this is where the problems happen)
I've tried using op.document.addHeaderAndFooter and what happens for some MyOp instances is that the code does not go pass IOperation(op.document.addHeaderAndFooter).Do(). No exceptions raised, simply "spins" and never finishes.
Note that the above call is actually happening inside the Do method of MyOp class implementing IOperation being run inside a different thread (already) since called via AsyncDo.
So, yes I'm trying to execute an IOperation(op.document.addHeaderAndFooter) inside MyOp's.IOperation.Do method.
What I then tried is executing IOperation(op.document.addHeaderAndFooter).Do() via AsyncDoAndWaitForFinish - the result is an exception "Wrong Thread".
Why?
p.s.
I hope the above is clear enough, if not here's some pseudo-code:
Code: Select all
//pseudo code
MyClass.IOperation.Do method
{
coreDoc = InstPXC.OpenDocumentFromFile
coreDoc.Props.OpenActions = null //just to do something with coreDoc
//and now the problematic part!
op = Inst.CreateOp(op.document.addHeaderAndFooter)
op.Do()
//THIS LINE IS NEVER REACHED *SOMETIMES* (randomly for some MyClass instances)
//IF tried like this
Inst.AsyncDoAndWaitForFinish(op) //-> raises "Wrong Thread"
}