private void BtnInvokeClick(object sender, EventArgs e) { _invokeCount++; // intercepting the result _service.ShowClients(new[] { new T42Contact { Name = new T42Name { FirstName = "Joe", LastName = "Smith" } }, new T42Contact { Name = new T42Name { FirstName = "Jane", LastName = "Doe" } } }, new ServiceOptions( (so, invocation, cmr, ex) => { Log($"{nameof(_service.ShowClients)} completed with {cmr} : {ex}"); if (cmr == null || cmr.Status != MethodInvocationStatus.Succeeded || ex != null) { Log("Cannot show client due to " + (cmr?.ToString() ?? "appropriate target method not found")); } })); // async contract result _service.GetState(state => { Log("State is " + state); }); int x = 5; // async handle the internal method result _service.CheckAsyncClientMethodResult(ref x, cmr => Log( $"{nameof(IServiceContract.CheckAsyncClientMethodResult)} completed with {cmr?.Status}")); // let's intercept the result and also add one additional value - to not break the contract (alter the interface) _service.TestAGMOptions("Hello", new ServiceOptions( builder => // we can tweak builder.SetInvocationTarget(MethodTargetType.Any) //we can check the current invocation arguments via .MethodInvocationContext.Arguments //add one additional value .SetContext(cb => cb.AddValue("AdditionalValue", _invokeCount % 2 == 0 ? "break" : Guid.NewGuid().ToString())) // let's set the logging level for that call .SetInvocationLoggingLevel(LogLevel.Debug), // intercept the result (operation, invocation, cmr, ex) => Log("Intercepted result: " + cmr.ToString()))); // let's consume some composite types, enums, arrays etc. CompositeType result = _service.SetCurrentInstrument(new[] { "RIC=VOD.L" }, "RIC", "VOD.L", "LN", "BaiKai", out SCIResultCode sciResultCode, out DateTime dt, out CompositeType outResponse); // try the custom rectangle serializer var offsetRect = _service.Offset(new Rectangle(0, 0, 50, 50), 20, 20); // JS friendly - unwrapped object var compositeUnwrapped = _service.GetUnwrapped("a,b,c,d,e", 15); // remote property var oldBounds = _service.Bounds; Log($"Old bounds : {oldBounds}"); _service.Bounds = new Rectangle(100, 100, 500, 500); var newBounds = _service.Bounds; Log($"New bounds : {newBounds}"); // multiple async results _service.CalculateSumAndMulAsync(2, 5, (i, i1) => { Log($"i = {i}; i1 = {i1}"); }); // composite async output _service.ComplexAsyncOutput(511, response => { Log("Complex async response " + response.Message); }); }