I'm not into ASP.NET, but as far as COM is concerned (to confirm what
Ryan said), if the component is marked as "Appartment" threaded, i.e
"lives" in a STA, you may only access it on the thread, on which the
component was initially created. There was some attribute (on the
<page> element), I think AspCompatible or something, which is set to
true, will automatically do this for you, though not sure.

HTH,
Stoyan

On 2/28/06, Ryan Heath <[EMAIL PROTECTED]> wrote:
> I hope for you the COM object is not bound to the thread is was created on.
> I remember things like (single) apartment threaded objects are bound
> to a certain thread.
>
> Good luck.
>
> // Ryan
>
> On 2/28/06, Andy Smith <[EMAIL PROTECTED]> wrote:
> > I have an ASP.NET application and I need to serialize access to an
> > external resource, in this case it's a COM interface to a QuickBooks
> > application. The SDK for QB exposes a COM component for access to it, but
> > it is not multithreaded. So I don't think, strictly speaking, I need a
> > Queue, and all that it usually implies (separate thread reading a
> > collection of messages). So, the long and the short of it is, I'm
> > wondering if I can get away with simply using this:
> >
> > if (!Monitor.TryEnter(object, timeout)) {
> >  throw Exception("Couldn't get lock.");
> > }
> > try {
> >   // do stuff with COM object...
> > } finally {
> >   Monitor.Exit();
> > }
> >
> > I'm wondering if I have each ASP.NET thread use this to access the COM
> > object, I've achieved the serialization I need, and avoided the need for
> > any separate background thread, Auto/ManualResetEvents, etc.
> >
> > Is this right, or am I oversimplifying it? I've done multi-threaded apps
> > before but I'm not an expert, so any help is appreciated.
> >
> > Thanks!
> >
> > Andy
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at http://discuss.develop.com
> >
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>


--

Cheers,
Stoyan

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to