Why the thread running a query is not reused between query executions?
Options
I'm having a problem with a Query that use a COM object.
The same COM object is reused between query executions, but since LINQPad uses STA thread by default and creates a new thread on each execution, the second execution fails with an InvalidComObjectException.
I can workaround the problem by enabling the option "Run Queries in MTA Threads", but this can be annoying since other functionality requiring STA Threads (e.g. DumpLive) will fail.
Is there a good reason not to reuse the same thread for multiple execution of a query?
Thanks,
Jeff Cyr
The same COM object is reused between query executions, but since LINQPad uses STA thread by default and creates a new thread on each execution, the second execution fails with an InvalidComObjectException.
I can workaround the problem by enabling the option "Run Queries in MTA Threads", but this can be annoying since other functionality requiring STA Threads (e.g. DumpLive) will fail.
Is there a good reason not to reuse the same thread for multiple execution of a query?
Thanks,
Jeff Cyr
Comments
-
There's no good reason that LINQPad cannot re-use the same thread between executions in the absence of errors/cancellation. I've modified LINQPad for the next release so that it works this way.
-
Great, that was quick!