
Signature
<http://www.midnightbeach.com>
> The dox are very emphatic that when you use a delegate's BeginInvoke,
> you must always call the delegate's EndInvoke:
[quoted text clipped - 12 lines]
> into BeginInvoke / EndInvoke's
> native code, so I can't look ....
Your code will run in some .NET context, an object can require more than
one context, and these occur as a chain, with the results from one
context being passed on to the next context handler.
Thus every method call, sync or async, will go through a chain of
context objects and each context will be allowed to handle the method
call in whatever way it likes. So one context may cache some objects
when the async call is started and this context handler will only
release those cached objects when you call EndInvoke. Of course, in most
cases, with objects run in the same application domain and accessed by a
single thread, you'll only have the standard context so for methods that
do not return results you may as well omit the call to EndInvoke.
However, this is not a good idea because if at a later state you decide
to run your object under COM+ or some other environment then .NET (or
another developer) may add a context.
It's a good habit to call EndInvoke. However, if you write the method
that is called asynchronously then you can indicate to .NET contexts
that callers won't call EndInvoke by using the [OneWay] attribute.
Richard

Signature
Fusion Tutorial: http://www.grimes.demon.co.uk/workshops/fusionWS.htm
Security Tutorial:
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Jon Shemitz - 30 Jan 2006 23:32 GMT
> Your code will run in some .NET context, an object can require more than
> one context, and these occur as a chain, with the results from one
[quoted text clipped - 11 lines]
> to run your object under COM+ or some other environment then .NET (or
> another developer) may add a context.
Thank you - this makes sense. However, while I may have misunderstood
Don Box's Ch 7, I thought that contexts and context switches and the
whole method-calls-as-messaging model only applied to classes that
inherit from ContextBoundObject?
> It's a good habit to call EndInvoke. However, if you write the method
> that is called asynchronously then you can indicate to .NET contexts
> that callers won't call EndInvoke by using the [OneWay] attribute.
But [OneWay] makes no guarantees, right? It's merely a post-MS (ie,
not even hinted at in the dox) convention, that various context may or
may not honor?

Signature
<http://www.midnightbeach.com>