Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //example:
- Service<IProxyInterface>.Use(service => service.MyAwesomeMethodCall());
- //code:
- public static class Service<T>
- {
- public static ChannelFactory<T> _channelFactory = new ChannelFactory<T>("");
- public static void Use(Action<T> block)
- {
- var proxy = (IClientChannel)_channelFactory.CreateChannel();
- proxy.OperationTimeout = new TimeSpan(0, 5, 0);
- var success = false;
- try
- {
- block((T)proxy);
- proxy.Close();
- success = true;
- }
- finally
- {
- if (!success)
- {
- proxy.Abort();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment