开发者

Why does ClientBase Dispose need to throw on faulted state?

开发者 https://www.devze.com 2023-01-09 02:58 出处:网络
Why does 开发者_如何学运维ClientBase Dispose need to throw on faulted state?Probably because you need to Abort it first:

Why does 开发者_如何学运维ClientBase Dispose need to throw on faulted state?


Probably because you need to Abort it first:

An object in the Faulted state is not closed and may be holding resources. The Abort method should be used to close an object that has faulted. If Close is called on an object in the Faulted state, a CommunicationObjectFaultedException is thrown because the object cannot be gracefully closed.

From ClientBase.Dispose doco:

Closes the client object.

You are probably getting CommunicationObjectFaultedException because you are calling Dispose (which calls Close) before aborting. Abort, then Dispose and you should be OK.

0

精彩评论

暂无评论...
验证码 换一张
取 消