Bug 4122 - Task.ContinueWith block not being called on device
Summary: Task.ContinueWith block not being called on device
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: Macintosh Other
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-03-28 07:31 UTC by James
Modified: 2012-03-28 10:06 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description James 2012-03-28 07:31:26 UTC
When I run the following code on the simulator the ContinueWith block is always called when the API call time exceeds 30 secs, however, if I run the same code in a device it never gets called:

    Task.Factory.StartNew(() => {
        // give the web service 30 seconds to respond
        var successful = Task.Factory.StartNew(() => {
            // do API call
	}, TaskCreationOptions.AttachedToParent).Wait(30000);
				
        if (successful)
        {
            // do other stuff
            return true;
        }
        else
            return false;
     }).ContinueWith(t => {
        // if the previous task did not throw an exception, continue on
        Console.WriteLine("Result of task: {0}", t.Result);
     }, TaskContinuationOptions.NotOnFaulted);

Weirdly, if the child task completes within the timeout period it works, however, I am testing how the app responds when there is a timeout (e.g. no network connection/jammed network/slow connection). 

No exception or anything raised, just doesn't call the code.
Comment 1 James 2012-03-28 09:55:01 UTC
Also removed the TaskContinuationOptions so it should always continue, still no joy.
Comment 2 James 2012-03-28 10:06:41 UTC
In fact, don't think this is a bug after (sorry!). I think the problem is the task is getting hung waiting on a response from the server as I just left it running and eventually the ContinueWith code ran after about 2 minutes.