ArgumentException - Use of undefined keyword value 1 for event TaskScheduled in async

可紊 提交于 2019-12-04 22:36:01

The exception can be ignored. Just hit play. Alternatively you can disable break on exceptions in debug -> exceptions menu.

The issue still exists, and the exception itself can be ignored as other answer said. But if the async operation is enclosed by try/catch, the exception would be caught and other operation in same try/catch brace would not be executed, that's the problem.

Just putting this before async operation would get better this.

try
{
    await Task.Delay(1);
}
catch
{
    // do nothing
}

Exception still occurs on Task.Delay(1), but after that it wouldn't occur on following async operation.

I solved this by adding

using System.Runtime.InteropServices.WindowsRuntime;

Do not remove this line. The automatic "sort and remove usings" will (in my case) remove it, causing this cryptic issue. No, I don't know why. But I know it's the cause.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!