/// <summary> /// async call Demo2 /// </summary> /// <returns>result</returns> private static string Demo2() { //Init Client var client2 = new ClientInvoker<IService2, Service2Client>(); // Config: AssemblyConfig -> DemoServiceContract.dll.config //invoke Async Request var dataAsync = string.Empty; var resultAsync = client2.InvokeRequestAsync( async (clientBase) => { dataAsync = await clientBase.GetData2Async(2); return !string.IsNullOrWhiteSpace(dataAsync); }); resultAsync.Wait(); return "Demo2() => " + nameof(resultAsync) + " -> " + resultAsync.Result + " | " + nameof(dataAsync) + " -> " + dataAsync; }
/// <summary> /// async call Demo2 /// </summary> /// <returns>result</returns> private static string Demo4() { //Init Client var client4 = new ClientInvoker<ServiceClient.ServiceReferenceDemo4.IService1, Service1ClientDemo4>(); // Config: GlobalAssemblyConfig -> DemoServiceClient.exe.config over static/const field/property called 'DefaultEndpointConfigurationName' //invoke Async Request var dataAsync = string.Empty; var resultAsync = client4.InvokeRequestAsync( async (clientBase) => { dataAsync = await clientBase.GetDataAsync(4); return !string.IsNullOrWhiteSpace(dataAsync); }); resultAsync.Wait(); return "Demo4() => " + nameof(resultAsync) + " -> " + resultAsync.Result + " | " + nameof(dataAsync) + " -> " + dataAsync; }