MSDN documentation states that :
StreamingContextStates.CrossAppDomain specifies that the source or destination context is a different app-domain.
I know what a开发者_如何学Pythonpp-domains are but still it doesn't help me understand the actual idea of StreamingContextStates
.
Can some one explain it to me in an easy (less technical) language.
I'm not that good at understanding a concept just by reading it's documentation.
The idea here is that if you want, you can save resources by using different serialization in different scenarios. For example, it might be that some of your data is in some OS resource that will work for your entire process.
If you have multiple AppDomain
s in a single process, and are using remoting to talk between them, then when you spot the CrossAppDomain
option you might just copy the underlying OS handle - that existing handle is just as valid from either AppDomain
, since the OS handles don't really know about app-domains.
IIRC, string
is actually valid over an entire process space, without need to serialize - so that might be an interesting case to just keep the reference.
Other options would be same-app-domain, same-machine, different-machines, etc.
IMO though, this just exposes you to additional complexity. It would only be worth worrying about in very specialized scenarios. In the general case it is better just to serialize to a pre-defined storage representation, and rehydrate.
精彩评论