zoukankan      html  css  js  c++  java
  • 委托

    一、WPF委托

    this.Dispatcher.Invoke(new Action(delegate
                                {
                                   
                                }));

    二、C#委托

    1、 Task.Factory.StartNew((a) =>
                {
                       //异步执行的代码
                }, objects);    //其中objects是一个参数集合
    2//声明委托
     public delegate string RequestDataDel(Uri x, string y);//括号内为需要的参数类型
    //同步
    public string RequestData(string Url, string Parameters)
            {
                RequestDataDel byteRe = RequestData;
                //同步调用委托
                IAsyncResult result = byteRe.BeginInvoke(new Uri(Url), Parameters, new AsyncCallback(ReturnResult), "AsycState:OK");
                RequestDataDel handler = (RequestDataDel)((AsyncResult)result).AsyncDelegate;
                var ss = handler.EndInvoke(result);
                return ss;
            }
     public string RequestData(Uri uri, string parameters)
            {
    }
    *****************************************************************************************************************************
    
    //异步
    方法A()
    {
      IAsyncResult result = byteRe.BeginInvoke(interfaceUri, string.Format("{0}", JsonConvert.SerializeObject(JSon)), new AsyncCallback(ReturnResult), "AsycState:OK");
    }
    //调用ReturnResult进行异步委托
    public static void ReturnResult(IAsyncResult result)
            {
                RequestDataDel handler = (RequestDataDel)((AsyncResult)result).AsyncDelegate;
                string backVal = handler.EndInvoke(result);
                if (!string.IsNullOrWhiteSpace(backVal))
                {
                }
            }
  • 相关阅读:
    iOS—UI —推送实现
    iOS—UI —懒加载
    iOS多线程和NSRunLoop概述
    ios安全性---AES加密
    iOS私有API
    iOS多线程 && Runloop
    iOS毛玻璃效果
    Swift -4-对象与类
    Swift -3-函数&闭包
    Swift -1- 简介&简单值&基本类型
  • 原文地址:https://www.cnblogs.com/lijianda/p/6831210.html
Copyright © 2011-2022 走看看