Re: Managed Asynchronous Pluggable Protocol and Threads
From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 02/03/05
- Next message: MvP: "RE: Can't navigate control when xsl is used"
- Previous message: Max K.: "Managed Asynchronous Pluggable Protocol and Threads"
- In reply to: Max K.: "Managed Asynchronous Pluggable Protocol and Threads"
- Next in thread: Max K.: "Re: Managed Asynchronous Pluggable Protocol and Threads"
- Reply: Max K.: "Re: Managed Asynchronous Pluggable Protocol and Threads"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 2 Feb 2005 20:02:05 -0500
"Max K." <maxk@eden.rutgers.edu> wrote in message
news:1107390883.318555.282940@g14g2000cwa.googlegroups.com
> Here are my observations. Originally my APP is created on a thread in
> STA apartment (debugger shows
> Thread.CurrentThread.AppartmentState=STA). When ReportProgress is
> called Thread.CurrentThread.AppartmentState is changed to MTA.
I suspect CLR got confused. In my experience, HTTP APP calls you back on
a worker thread that did not initialize COM at all.
URLMon blatantly disregards COM threading rules. It only works because
direct interface pointers are used throughout, no marshalling is
involved, so COM runtime is out of the picture and does not have a
chance to complain. The whole thing is held together with bubble gum and
duct tape, I had to tread very carefully to avoid breaking it.
I shudder to think about how .NET runtime would behave when thrown into
this mess. I have my doubts about the feasibility of a managed APP
handler.
> I suspected that system has a problem calling my Continue after I
> called target Switch and tried just for troubleshooting to call
> Continue myself from my Switch method.
But that defeats the whole point. Switch / Continue pair is there for a
reason - it allows the APP to request the host application to call it
back on the main STA thread, mostly when it needs to do honest COM stuff
that would break from the worker. Essentially, when you call Switch from
the worker, MSTHML posts a message to the hidden window it maintains on
the main thread. When the message arrives, it calls Continue on you,
thus effectively switching to the main thread.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
- Next message: MvP: "RE: Can't navigate control when xsl is used"
- Previous message: Max K.: "Managed Asynchronous Pluggable Protocol and Threads"
- In reply to: Max K.: "Managed Asynchronous Pluggable Protocol and Threads"
- Next in thread: Max K.: "Re: Managed Asynchronous Pluggable Protocol and Threads"
- Reply: Max K.: "Re: Managed Asynchronous Pluggable Protocol and Threads"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|