private static async Task <AutomationResult> TryActionAsync(Expression <Action <IVidCoderAutomation> > action) { try { string betaString = string.Empty; if (CommonUtilities.Beta) { betaString = "Beta"; } using (var client = new PipeClient <IVidCoderAutomation>("VidCoderAutomation" + betaString)) { client.SetLogger(Console.WriteLine); await client.ConnectAsync().ConfigureAwait(false); await client.InvokeAsync(action).ConfigureAwait(false); } return(AutomationResult.Success); } catch (PipeInvokeFailedException exception) { WriteError(exception.ToString()); return(AutomationResult.FailedInVidCoder); } catch (Exception) { return(AutomationResult.ConnectionFailed); } }
private static async Task RunClientAsync() { var pipeClient = new PipeClient <IAdder>("mypipe"); pipeClient.SetLogger(message => Console.WriteLine(message)); try { await pipeClient.ConnectAsync().ConfigureAwait(false); WrappedInt result = await pipeClient.InvokeAsync(adder => adder.AddWrappedNumbers(new WrappedInt { Num = 1 }, new WrappedInt { Num = 3 })).ConfigureAwait(false); Console.WriteLine("Server add result: " + result.Num); await pipeClient.WaitForRemotePipeCloseAsync(); Console.WriteLine("Server closed pipe."); } catch (Exception exception) { Console.WriteLine("Exception in pipe processing: " + exception); } }
public async Task RunAsync() { var pipeClient = new PipeClient <IAdder>("mypipe"); await pipeClient.ConnectAsync(); int result = await pipeClient.InvokeAsync(adder => adder.AddNumbers(1, 3)); }