The correct course of action will be that the creators of some disposable objects slightly deviate from the Microsoft rule that performs any action on the remote object, should throw an exception and instead follow the more general rule that the exception should be thrown at any time when the post -conditions of the method cannot be met. If the purpose of the Cancel method is to ensure that no one continues to view the work as live, and even before the Cancel method is called, everyone considers the work dead, then the post-condition for the method is fulfilled regardless of whether it is located whether the object.
Typically, code outside of a well-designed object should not ask if it has been deleted, except to possibly state that it was. Instead, the object itself must provide methods whose value on the placed object will be clear and unambiguous. These methods may internally use the IsDisposed flag, but it will need to use any lock necessary to prevent race conditions. In general, a template
if (! myThing.isDisposed)
myThing.DoSomething ();
is a sign that myThing should really support the DoSomethingIfNotDisposed method (possibly called TryDoSomething). If you can't do this, my tendency might be to write your own DoSomethingIfNotDisposed extension method and use Try / Catch to drown out ObjectDisposedException (or any specific exception that the object should throw).
source share