theraot / Theraot

Backporting .NET and more: LINQ expressions in .net 2.0 - nuget Theraot.Core available.
MIT License
158 stars 30 forks source link

Net 3.5: Task.Wait() hangs on cancellation #120

Closed ig-sinicyn closed 4 years ago

ig-sinicyn commented 4 years ago

Net 3.5 + Theraot.Core v3.1.3:

        public void TestWaitForCancellation()
        {
            var cts = new CancellationTokenSource();
            var task = TaskEx.Run(
                async () =>
                {
                    try
                    {
                        await TaskEx.Delay(_timeout10, cts.Token);
                    }
                    catch (OperationCanceledException) { }
                },
                cts.Token);
            cts.CancelAfter(_timeout1);
            task.Wait(); // never completes
        }

Same code on net 4.0 works fine.

theraot commented 4 years ago

Uploading nuget version 3.1.4