Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task.Delay with CancellationToken support #2405

geoffreymcgill opened this issue Feb 17, 2017 · 1 comment


None yet
3 participants
Copy link

commented Feb 17, 2017

Creates a cancellable task that completes after a time delay.

Steps To Reproduce

using System;
using System.Threading;
using System.Threading.Tasks;

public class Example
    public static void Main()
        CancellationTokenSource source = new CancellationTokenSource();

        var t = Task.Run(async delegate
            // Support required for .Delay with Token
            await Task.Delay(1000, source.Token);

            return 42;

            // Support required for .Wait
        catch (AggregateException ae) 
            foreach (var e in ae.InnerExceptions)
                Console.WriteLine("{0}: {1}", e.GetType().Name, e.Message);

        Console.Write("Task t Status: {0}", t.Status);

        if (t.Status == TaskStatus.RanToCompletion)
            Console.Write(", Result: {0}", t.Result);


Expected Result

TaskCanceledException: A task was canceled.
Task t Status: Canceled

Actual Result

Compiler Exception

See Also


This comment has been minimized.

Copy link

commented May 21, 2019

The implementation works fine and will be included next Bridge release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.