public void TestPolledRpcAsync() { Console.WriteLine("TestPolledRpcAsync"); var def = new RpcDefinition(1, "myfunc1", new List <RpcParamDef> { new RpcParamDef("param1", Value.MakeDouble(0.0)) }, new List <RpcResultsDef> { new RpcResultsDef("result1", NtType.Double) }); RemoteProcedureCall.CreatePolledRpc("func1", def); Console.WriteLine("Calling RPC"); long call1Uid = RemoteProcedureCall.CallRpc("func1", RemoteProcedureCall.PackRpcValues(new [] { Value.MakeDouble(2.0) })); CancellationTokenSource source = new CancellationTokenSource(); var task = RemoteProcedureCall.PollRpcAsync(source.Token); bool completed = task.Wait(TimeSpan.FromSeconds(1)); if (!completed) { source.Cancel(); } Assert.That(completed, Is.True); Assert.That(task.IsCompleted, Is.True); Assert.That(task.Result, Is.Not.Null); Assert.That(task.Result.HasValue); IList <byte> toSendBack = Callback1(task.Result.Value.Name, task.Result.Value.Params, new ConnectionInfo()); Assert.That(toSendBack.Count, Is.Not.EqualTo(0)); RemoteProcedureCall.PostRpcResponse(task.Result.Value.RpcId, task.Result.Value.CallUid, toSendBack); Console.WriteLine("Waiting for RPC Result"); byte[] result = null; RemoteProcedureCall.GetRpcResult(true, call1Uid, out result); var call1Result = RemoteProcedureCall.UnpackRpcValues(result, new [] { NtType.Double }); Assert.AreNotEqual(0, call1Result.Count, "RPC Result empty"); Console.WriteLine(call1Result[0].ToString()); }