Changeset 5707 for branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/WcfServicePool.cs
- Timestamp:
- 03/16/11 13:31:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.3/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/WcfServicePool.cs
r5588 r5707 58 58 } 59 59 60 public Disposable <T> GetService() {60 public DisposableWrapper<T> GetService() { 61 61 try { 62 62 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { 63 63 var factory = ClientFactory.CreateChannelFactory<T>(endpointName, hostAddress, userName, password); 64 return new Disposable<T>(factory.Obj.CreateChannel()); 64 var disposable = new DisposableWrapper<T>(factory.CreateChannel()); 65 disposable.OnDisposing += new EventHandler<EventArgs<object>>(disposable_OnDisposing); 66 return disposable; 65 67 } else { 66 68 var factory = ClientFactory.CreateChannelFactory<T>(endpointName, hostAddress); 67 return new Disposable<T>(factory.Obj.CreateChannel()); 69 var disposable = new DisposableWrapper<T>(factory.CreateChannel()); 70 disposable.OnDisposing += new EventHandler<EventArgs<object>>(disposable_OnDisposing); 71 return disposable; 68 72 } 69 73 } … … 81 85 } 82 86 } 87 88 private void disposable_OnDisposing(object sender, EventArgs<object> e) { 89 DisposeCommunicationObject((ICommunicationObject)e.Value); 90 } 91 92 public static void DisposeCommunicationObject(ICommunicationObject obj) { 93 if (obj != null) { 94 if (obj.State != CommunicationState.Faulted && obj.State != CommunicationState.Closed) { 95 try { obj.Close(); } 96 catch { obj.Abort(); } 97 } else { 98 obj.Abort(); 99 } 100 } 101 } 83 102 } 84 103 }
Note: See TracChangeset
for help on using the changeset viewer.