private static void GetName() { using (ChannelFactory <PersonService.WcfService> channelFactory = new ChannelFactory <PersonService.WcfService>("WSHttpBinding_WcfService")) { PersonService.WcfService proxy = channelFactory.CreateChannel(); using (proxy as IDisposable) { Thread.Sleep(20); Console.WriteLine(proxy.getName("myName by sync")); } } }
private async static void GetNameAsync() { using (ChannelFactory <PersonService.WcfService> channelFactory = new ChannelFactory <PersonService.WcfService>("WSHttpBinding_WcfService")) { PersonService.WcfService proxy = channelFactory.CreateChannel(); using (proxy as IDisposable) { Thread.Sleep(20); string res = await proxy.getNameAsync("myName by async Test"); Console.WriteLine(res); } } }