From e4158ecb3c216818d6034e9a88fa34048ee764ca Mon Sep 17 00:00:00 2001 From: conceptdev Date: Thu, 2 Jan 2020 12:25:32 -0800 Subject: [PATCH] [background] update delegate implementation fixes https://github.com/MicrosoftDocs/xamarin-docs/issues/2420 from docs --- .../SimpleBackgroundTransferViewController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs b/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs index 00e90b268..cfcc92983 100644 --- a/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs +++ b/SimpleBackgroundTransfer/SimpleBackgroundTransfer/SimpleBackgroundTransferViewController.cs @@ -70,8 +70,8 @@ public UIImageView ImageView { } } - public class UrlSessionDelegate : NSUrlSessionDownloadDelegate - { + public class UrlSessionDelegate : NSObject, INSUrlSessionDownloadDelegate + { public SimpleBackgroundTransferViewController controller; public UrlSessionDelegate (SimpleBackgroundTransferViewController controller) @@ -79,7 +79,7 @@ public UrlSessionDelegate (SimpleBackgroundTransferViewController controller) this.controller = controller; } - public override void DidWriteData (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, long bytesWritten, long totalBytesWritten, long totalBytesExpectedToWrite) + public void DidWriteData (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, long bytesWritten, long totalBytesWritten, long totalBytesExpectedToWrite) { Console.WriteLine ("Set Progress"); if (downloadTask == controller.downloadTask) { @@ -91,7 +91,7 @@ public override void DidWriteData (NSUrlSession session, NSUrlSessionDownloadTas } } - public override void DidFinishDownloading (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, NSUrl location) + public void DidFinishDownloading (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, NSUrl location) { Console.WriteLine ("Finished"); Console.WriteLine ("File downloaded in : {0}", location); @@ -121,7 +121,7 @@ public override void DidFinishDownloading (NSUrlSession session, NSUrlSessionDow } } - public override void DidCompleteWithError (NSUrlSession session, NSUrlSessionTask task, NSError error) + public void DidCompleteWithError (NSUrlSession session, NSUrlSessionTask task, NSError error) { Console.WriteLine ("DidComplete"); if (error == null) @@ -137,12 +137,12 @@ public override void DidCompleteWithError (NSUrlSession session, NSUrlSessionTas controller.downloadTask = null; } - public override void DidResume (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, long resumeFileOffset, long expectedTotalBytes) + public void DidResume (NSUrlSession session, NSUrlSessionDownloadTask downloadTask, long resumeFileOffset, long expectedTotalBytes) { Console.WriteLine ("DidResume"); } - public override void DidFinishEventsForBackgroundSession (NSUrlSession session) + public void DidFinishEventsForBackgroundSession (NSUrlSession session) { using (AppDelegate appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate) { var handler = appDelegate.BackgroundSessionCompletionHandler;