Skip to content

VS Debugger Stops Working After Returning from "await" Call #14

@Chadt54

Description

@Chadt54

Create a .NET Core Standard 2.1 CLI project in Visual Studio, then use this code, set a breakpoint at the "await" line, then run and step through the code. When the debugger is finished stepping through the "GetPackage" function, as soon as it returns from the function, the program immediately executes the rest of the code and completes without the expected behavior of the debugger continuing to the next "int g = 9;" line, stopping, and waiting.

Any idea why the ITask is breaking the VS debugger?

using MorseCode.ITask;
using System;
using System.Threading.Tasks;

namespace ConsoleApp1_AsyncBugTest_NETCore
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Test test = new Test();
            int j = 0;
            await test.GetPackage();

            int g = 9;

            Console.WriteLine("Hello World!");
        }

        public class PackageBase
        {

        }

        public class NullPackage : PackageBase
        {

        }


        public class Test
        {
            NullPackage nullPackage;
            public async ITask<NullPackage> GetPackage()
            {
                if (nullPackage == null)
                    nullPackage = new NullPackage();

                return await Task.FromResult(nullPackage).AsITask();
            }
        }
    }
}

Edit/Update: If I remove the ITask and revert back to using a regular Task, the debugger acts as expected, so it's definitely a problem with ITask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions