当前位置: 代码迷 >> Windows Mobile >> wp8.1 委托与异步回调有关问题
  详细解决方案

wp8.1 委托与异步回调有关问题

热度:213   发布时间:2016-04-25 07:10:04.0
wp8.1 委托与异步回调问题
  public delegate void delegate_Getcomment(string id);
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            delegate_Getcomment getcomment = new delegate_Getcomment(GetComment);

            IAsyncResult result = getcomment.BeginInvoke("0", new AsyncCallback(response), "AsycState:OK");
        }
        private void GetComment(string id)
        {

            Thread.Sleep(3000);
          

        }
        void response(IAsyncResult result)
        {
            MessageBox.Show("异步回调完成");
        }

如上所示。这代码能在桌面应用完美运行,但是换到wp8.1 就不行了 ,有大神知道要怎么改吗。
------解决思路----------------------
第一个方法接受一个委托参数,用第二个方法作为参数构造委托对象给传给第一个方法就是了。

我猜测你的意思是一个页面中打开或弹出第2个页面,第二个页面执行完成后返回一个结果,然后再把这个结果给页面1的一个方法并执行吧?
  相关解决方案