示例#1
0
 /// <summary>
 /// 调用JSON-RPC服务(异步),泛型
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="successedAction">执行成功后调用的函数</param>
 /// <param name="failedAction">执行失败后调用的函数</param>
 /// <param name="method">JSON-RPC方法名</param>
 /// <param name="args">JSON-RPC方法接收的参数,此参数为可变数组</param>
 public static void CallAsync <T>(Action <T> successedAction, Action <Exception> failedAction, string method, params object[] args)
 {
     Task.Factory.StartNew(() =>
     {
         var asyncState = new CallAsyncResult <T>()
         {
             Method            = method,
             Args              = args,
             SuccessedCallBack = successedAction,
             FailedCallBack    = failedAction
         };
         ProcessCallAsync <T>(asyncState);
     });
 }
示例#2
0
 /// <summary>
 /// 调用JSON-RPC服务(异步)
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="successedAction">执行成功后调用的函数</param>
 /// <param name="failedAction">执行失败后调用的函数</param>
 /// <param name="method">JSON-RPC方法名</param>
 /// <param name="args">JSON-RPC方法接收的参数,此参数为将参数数组对象化的写法,如new { param1 = "A", param2 = "B"  }</param>
 public static void CallWithDeclaredParamsAsync <T>(Action <T> successedAction, Action <Exception> failedAction, string method, object args)
 {
     Task.Factory.StartNew(() =>
     {
         var asyncState = new CallAsyncResult <T>()
         {
             IsDeclaredParams  = true,
             Method            = method,
             DeclaredArgs      = args,
             SuccessedCallBack = successedAction,
             FailedCallBack    = failedAction
         };
         ProcessCallAsync <T>(asyncState);
     });
 }