Finish iOS background task, when move it foreground
===

I use code samples from http://software.tavlikos.com/2010/12/08/multitasking-in-ios-the-monotouch-way-part-i/ article to run background task on iOS application DidEnterBackground event.

Task is heavy and long timing - near 1 minute. If user force application back to foreground, he should wait till task is finished. It's a bit weak.

I tried to use WillEnterForeground event: 

		public override void WillEnterForeground (UIApplication application)
		{
			if (taskId != 0) {
				Console.WriteLine("Finish previous task"); 
				application.EndBackgroundTask(taskId);
				taskId = 0;
			}
		}

but it calls **after** task ending.

How to break background task execution if user switched to app before it's done?