Bug 16992 - CancellationTokenSource Cancel calls callbacks in reverse order
Summary: CancellationTokenSource Cancel calls callbacks in reverse order
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-12-30 10:15 UTC by donsyme
Modified: 2014-01-01 05:01 UTC (History)
2 users (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 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 donsyme 2013-12-30 10:15:57 UTC
The following F# core library test is failing on Mono OSX:

        use cts = new CancellationTokenSource()
        let current = ref 0
        let action (o:obj) = Assert.AreEqual(!current, (unbox o : int)); current := !current + 1
        cts.Token.Register(Action<obj>(action), box 2) |> ignore
        cts.Token.Register(Action<obj>(action), box 1) |> ignore
        cts.Token.Register(Action<obj>(action), box 0) |> ignore
        cts.Cancel()

This indicates that when "Cancel" is called, the actions are being called in reverse order - the first one is called first etc., when .NET compatibility means they should be called in reverse order - the last registered is called first.
Comment 1 Marek Safar 2014-01-01 05:01:48 UTC
Fixed in master