?
Close不一定会成功,所以需要Abort。
- ChannelFactory channel = new ChannelFactory<IService1>("bindingName");
- IService1 client = channel.CreateChannel();
- try
- {
- ????client.Say("Hello, world!");
- ????client.Close();
- }
- catch (CommunicationException e)
- {
- ????//...
- ????client.Abort();
- }
- catch (TimeoutException e)
- {
- ????//...
- ????client.Abort();
- }
- catch (Exception e)
- {
- ????//...
- ????client.Abort();
- }
时间: 2024-10-08 00:28:44