async void ProcessMetadataItems() { Console.WriteLine("ProcessMetadataItems"); NSMetadataItem[] metadataItems = documentMetadataQuery.Results; // We only expect a single result to be returned by our NSMetadataQuery since we query for a specific file. if (metadataItems.Length == 1) { var url = (NSUrl)metadataItems [0].ValueForAttribute(NSMetadataQuery.ItemURLKey); if (document != null) { document.Close(null); } document = new ListDocument(url); var success = await document.OpenAsync(); if (!success) { Console.WriteLine("Couldn't open document: {0}.", document.FileUrl.AbsoluteString); return; } ResetContentSize(); TableView.ReloadData(); } }
async void UpdateList() { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; var success = await document.OpenAsync(); if (!success) { // In your app you should handle this gracefully. Console.WriteLine("Couldn't open document: {0}.", DocumentURL.AbsoluteString); throw new InvalidProgramException(); } TableView.ReloadData(); UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; }
async void FetchInfo(TaskCompletionSource <object> tcs) { ListDocument document = new ListDocument(Url); bool success = await document.OpenAsync(); if (success) { Color = document.List.Color; Name = document.LocalizedName; tcs.SetResult(null); document.Close(null); } else { tcs.SetException(new InvalidOperationException("Your attempt to open the document failed.")); } }