Bug 236 - TPL cannot use main UI thread TaskScheduler
Summary: TPL cannot use main UI thread TaskScheduler
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Jérémie Laval
URL:
Depends on:
Blocks:
 
Reported: 2011-08-08 18:36 UTC by Jérémie Laval
Modified: 2011-08-11 07:08 UTC (History)
1 user (show)

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


Attachments
Repro (4.92 KB, application/zip)
2011-08-08 18:36 UTC, Jérémie Laval
Details


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 GitHub or Developer Community 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 FIXED

Description Jérémie Laval 2011-08-08 18:36:17 UTC
Created attachment 92 [details]
Repro

In order to run some code off the UI thread, and some on, the TaskScheduler
"TaskScheduler.FromCurrentSynchronizationContext()" is used with a ContinueWith
of the background task.

However, either ContinueWith is broken or the UI TaskScheduler is broken
because such synchronized tasks end up executing on the background thread
instead of the main UI thread.

Steps to reproduce the problem:

            var t = Task.Factory.StartNew(() => {
                return 42;
            });

            t.ContinueWith((r) => {

                // DO UI WORK ON UI THREAD

            }, TaskScheduler.FromCurrentSynchronizationContext());


There is an attached project that demos this bug. Watch the console output.
Comment 1 Jérémie Laval 2011-08-11 07:08:47 UTC
Fixed by toshok, see https://bugzilla.novell.com/show_bug.cgi?id=690944#c3