TheSwamp

Code Red => .NET => Topic started by: CrockettScience on June 06, 2019, 12:13:32 PM

Title: About Document.SendStringToExecute()
Post by: CrockettScience on June 06, 2019, 12:13:32 PM
I'm working with a command in C# where we initialize a pack of documents based on certain criteria. It involves a queue of documents being created, edited, and saved. The way we do this is we create the Doc, switch to it, then SendStringToExecute() with a hidden command that does the initializing, saves it to file, then checks the queue to see if there's more and repeats. This way, each document is edited in it's own document context, which we need to do for reasons I can't get into.

It works most of the time, but quite commonly, it crashes at random in such a way that isn't reproducible. After some testing, the problem seems to go away when the second boolean argument of SendStringToExecute(), that is, wrapUpInactiveDoc, is set to true. However, the only problem there is then SendStringToExecute() throws an eInvalidInput error every time it's called, and then crashes when all the commands are complete. The documents end up otherwise unscathed, It's just inconvenient and bad presentation for our clients.

So I want to know, what exactly does wrapUpInactiveDoc = true actually do, why does it throw an eInvalidInput exception, and how can I do this in a way that doesn't throw that error.
Title: Re: About Document.SendStringToExecute()
Post by: dgorsman on June 06, 2019, 07:50:32 PM
Backing up a step... how many drawings are we talking about?  Dozens?  Hundreds?
Title: Re: About Document.SendStringToExecute()
Post by: CrockettScience on June 07, 2019, 11:39:32 AM
At most, it could possibly be 1 or 2 dozens. Or only a handful. It really depends on the project.

But let's assume worst case scenario for the sake of stability. Is it possible to have too many?
Title: Re: About Document.SendStringToExecute()
Post by: CrockettScience on June 07, 2019, 01:00:46 PM
Hmm, it seems as though the problem is unchanged even when I close each document after I'm done with it.
Title: Re: About Document.SendStringToExecute()
Post by: kdub_nz on June 08, 2019, 07:04:05 PM
Is the Save done in your code or by code dependant on the SendString ?
I s'pose my real question is how complex is the command you are passing ?

I recall reading 'somewhere' recommendations about the use of wrapUpInactiveDoc, but sorry, age is affecting my memory.

added afterthought :
Are you doing the Save inside a transaction Scope ?
Title: Re: About Document.SendStringToExecute()
Post by: CrockettScience on June 13, 2019, 02:02:56 PM
Save is done by the Database method SaveAs(), and after the transaction is closed.
Title: Re: About Document.SendStringToExecute()
Post by: CrockettScience on June 13, 2019, 05:31:31 PM
I was finally able to get the crashes to stop by executing the Database method CloseInput(true) on the document before working on another. Don't ask me why  :idiot2: