From bffa511ecb8f74b2d4a42418a130d0c83c9723cf Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Wed, 25 Sep 2019 17:02:44 -0500 Subject: [PATCH] Fix threading issue when NFC scan times out (#387) - https://github.com/xamarin/ios-samples/issues/385 --- .../NFCTagReader/MessagesTableViewController.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ios11/NFCTagReader/NFCTagReader/MessagesTableViewController.cs b/ios11/NFCTagReader/NFCTagReader/MessagesTableViewController.cs index b6cec733..527878f6 100644 --- a/ios11/NFCTagReader/NFCTagReader/MessagesTableViewController.cs +++ b/ios11/NFCTagReader/NFCTagReader/MessagesTableViewController.cs @@ -73,12 +73,10 @@ namespace NFCTagReader if (readerError != NFCReaderError.ReaderSessionInvalidationErrorFirstNDEFTagRead && readerError != NFCReaderError.ReaderSessionInvalidationErrorUserCanceled) { - - var alertController = UIAlertController.Create("Session Invalidated", error.LocalizedDescription, UIAlertControllerStyle.Alert); - alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); - DispatchQueue.MainQueue.DispatchAsync(() => - { - this.PresentViewController(alertController, true, null); + BeginInvokeOnMainThread (() => { + var alertController = UIAlertController.Create ("Session Invalidated", error.LocalizedDescription, UIAlertControllerStyle.Alert); + alertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, null)); + PresentViewController (alertController, true, null); }); }