Groups | Blog | Home
all groups > dotnet interop > october 2004 >

dotnet interop : Should not automate Office from a worker thread in VB.NET?


Robin Tucker
10/20/2004 8:39:27 PM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrconthreadingsupportinoffice.asp

This info (above) means to me that I should not automate Word from a thread.
I am currently automating Word from a worker thread, not my main process.
However, I thought that as I actually created my instance of Word on the
same thread I'm automating it from (the worker thread) this should not be an
issue. Is it basically saying I have to automate Word from my main process,
not a worker thread, no-matter how\when the automation objects get created?

(this is related to the "Message filter indicates that the application is
busy." exception I am occassionally getting. This exception occurs
specifically when I'm fiddling about with one word document while my
application is generating a report in the background via. automation).


Sunny
10/21/2004 9:45:43 AM
Hi,

In article <cl6etf$m3l$1$830fa79d@news.demon.co.uk>,
idontwanttobespammedanymore@reallyidont.com says...
[quoted text, click to view]

From my experience so far I understand this:
1. If you create your own thread, and make its AppartmentState to be
STA, it is safe to automate Office, if you create the the Office object
in the same thread. Then the calls are serialized correctly.
2. But if you try to access an object, which is created in another
thread, this is not supported and will fail.

Please, read the thread COM, STA threads and internal threads, started
by me a few days ago. Some clever guys there have input useful
information.

Cheers
arslcs NO[at]SPAM gmail.com
10/21/2004 6:52:20 PM
Buddy!
i need to do the same stuff?
can u guide me
my emailis arslcs@gmail.com
i want to generate a report on existing template using data in my app.
regards



[quoted text, click to view]
Robin Tucker
10/21/2004 8:01:17 PM
Thanks, I didn't set the apartment state of my thread so I guess it was
whatever it is by default (unknown). I've set it to STA and will do some
more testing however.

[quoted text, click to view]

Robin Tucker
10/22/2004 11:37:28 AM
Sorry, I have enough work to do already :)

[quoted text, click to view]

AddThis Social Bookmark Button