2
로 만든 후 클라이언트를 폐기하고, documentation on msdn에 따라, 클라이언트를 만들 수있는 방법이내 현재의 생산 코드에서 WebChannelFactory
using (WebChannelFactory<IServiceInterface> cf
= new WebChannelFactory<IServiceInterface>("http://service.url"))
{
IServiceInterface client = cf.CreateChannel();
client.CallTheMethod();
}
내가이 인터페이스가 주어진 것입니다 : 그러나
public interface IServiceInterface
{
void CallTheMethod();
}
을 WebChannelFactory에 의해 생성 된 객체 클라이언트도 IDisposable을 구현한다는 것을 알게되었습니다. 그래서이 객체도 처분하고 싶습니다. 나는 다른 방법을 찾지 못했습니다 :
using (WebChannelFactory<IServiceInterface> cf
= new WebChannelFactory<IServiceInterface>("http://service.url"))
using(IDisposable client = (IDisposable)cf.CreateChannel())
{
((IServiceInterface)client).CallTheMethod();
}
나는 이것을 찾지 못했습니다. 따라서 :
- 정말 처리해야합니까? 제 말은 공장을 처분 할 때 처분 될 수 있다는 것입니다 (공장에서 작성한 모든 오브젝트에 대한 참조가 유지되는 경우)?
- 그렇다면 더 좋은 방법이 있습니까?
당신은 내 질문에 정말로 대답하지 않았지만 당신은 나에게 좋은 독서를 제공합니다. 나는 대답을 받아들입니다. 감사. –