private void DownloadIndex(Action <string> onFinished) { try { var ec = new FileDownload(); var pd = new ProgressDialog(this); pd.SetMessage(Resources.GetText(Resource.String.Download_LoadingData)); pd.SetCancelable(false); pd.Show(); ec.OnFinishedAction = (result) => { MainThread.BeginInvokeOnMainThread(() => { onFinished.Invoke(result); pd.Hide(); }); }; ec.OnError = (message) => { MainThread.BeginInvokeOnMainThread(() => { pd.Hide(); PopupHelper.ErrorDialog(this, Resource.String.Download_ErrorDownloading, message); }); }; ec.Execute(GpxFileProvider.GetIndexUrl()); } catch (Exception ex) { PopupHelper.ErrorDialog(this, Resource.String.Download_ErrorDownloading, ex.Message); } }