16

What is ContextBoundObject used for? The documentation mentions 'contexts', which seem to be programatically defined, but fails to give any explanation as to what one is.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
thecoop
  • 45,220
  • 19
  • 132
  • 189
  • It's an atrocity. It's paved with pitfalls. I don't see a reason to use it, but it makes an interesting read: http://www.albahari.com/threading/part2.aspx#_Synchronization_Contexts – HuBeZa Jul 09 '18 at 06:20

2 Answers2

9

It's the base class providing facilities for synchronization domains in .NET (a little known feature in since .NET 1.0)

http://msdn.microsoft.com/en-us/magazine/dd569749.aspx

http://www.ddj.com/architect/184405771

Matt Hinze
  • 13,577
  • 3
  • 35
  • 40
4

This explanation sounds completely different than the accepted answer, but it makes more intuitive sense:

So what about ContextBoundObject?

Firstly, it allows you to do everything you can do with MarshalByRef object. Secondly, it allows you to do more. You can take control over the details of control over object creation, proxy creation, and marshalling method calls.

Community
  • 1
  • 1
Qwertie
  • 16,354
  • 20
  • 105
  • 148