Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ChannelFactory<IService1> factory = new ChannelFactory<IService1>("BasicHttpBinding_IService1");
- Task<string> t1 = Task<string>.Factory.StartNew(() => { return factory.CreateChannel().GetData(2); });
- Task<string> t2 = Task<string>.Factory.StartNew(() => { return factory.CreateChannel().GetData(5); });
- Task.Factory.ContinueWhenAll(new[] { t1, t2 }, t =>
- {
- foreach (var task in t)
- {
- //get result here
- }
- });
- [ServiceContract(Namespace = "X", Name = "TheContract")]//Server side contract
- public interface IService1
- {
- [OperationContract]
- string GetData(int value);
- }
- [ServiceContract(Namespace = "X", Name = "TheContract")]//client side contract
- public interface IService1Async
- {
- [OperationContract]
- string GetData(int value);
- [OperationContract]
- Task<string> GetDataAsync(int value);
- }
- ChannelFactory<IService1Async> factory = new ChannelFactory<IService1Async>("BasicHttpBinding_IService2");
- var t1 = factory.CreateChannel().GetDataAsync(2);
- var t2 = factory.CreateChannel().GetDataAsync(5);
- Task.Factory.ContinueWhenAll(new[] { t1, t2 }, (Task<string>[] t) =>
- {
- foreach (var task in t)
- {
- //get result here
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement