Scott Davies
Scott Davies

Reputation: 3755

Why doesn't DomainContext from WCF RIA Services implement the IDisposable pattern?

Just doing some work with RIA services and I see in the MSDN documentation that neither it or any parents up its' hierarchy implement IDisposable. I'm wondering what the design decision was for this...as DomainContext is a stateful resource, wouldn't it be nice to have a Dispose() to release it when done ?

Thanks,

Scott

Upvotes: 1

Views: 459

Answers (1)

Nikhil Kothari
Nikhil Kothari

Reputation: 5225

A stateful object doesn't imply IDisposable is required.

The real question is what would you do in Dispose.

At best the only thing you could theoretically do is abort any pending web requests. However, that is probably better left to the app developer to call the right Cancel method - since Load/Submit are all explicit calls, Cancel should be as well.

The existence of IDisposable would be confusing as well - when is it required to be called, and when not, given the lack of concrete scenarios.

Hence no IDisposable on DomainContext.

Upvotes: 2

Related Questions