you are calling a UIKit method that can only be invoked from the UI thread.

参考方案1:http://blog.csdn.net/joyhen/article/details/20471217

参考方案2:https://developer.xamarin.com/api/member/MonoTouch.Foundation.NSObject.BeginInvokeOnMainThread/p/MonoTouch.Foundation.NSAction/

// Invoked in response to a button clicked on the UI.
void StartDownload ()
{
    status.Text = "Downloading file...";
    ThreadPool.QueueUserWorkItem (BackgroundDownload);
}
// This is the background helper
BackgroundDownload ()
{
    var wc = new WebClient ();
    wc.DownloadFile (myUrl, "/tmp/largeFile.txt");
    // When the download is complete, notify the UI
    BeginInvokeOnMainThread (delegate {
        status.Text = "Download has been completed";
    });
}

 

posted @ 2018-03-01 13:06  ziwuxian  阅读(139)  评论(0)    收藏  举报