简体   繁体   中英

c# core async/await stops debugging

I have a solution with multiple projects. Its build in .NET Core 2.2 and uses for example .NET EF. When calling a async method the debugger stops, no exception, try.. catch around it doesn't catch the error, debugger goes direct to the end of the console application. Cleaned up all bin/obj folders, removed .vs folder, checked all nuget packages for updates.

The code where it stopped it this moment is where I query EF async. But before this I got the same error while executing other async functions of web-requests. All thirdparty libraries from Microsoft. After adding .wait() or .result the problem is solved and I can contine.

tRepository.Queryable().Where(q => q.Tenant.Guid == iBaseTenant.Guid).ToListAsync();

The program '[17052] dotnet.exe' has exited with code 0 (0x0). The program '[17052] dotnet.exe: Program Trace' has exited with code 0 (0x0).

Found the solution, I forgot to add a await on a higher level. This function itself had the await, but the function calling this function was executed via a foreach loop where this did't wait for the result of all those items.

So when you have the same issue, please check if ALL levels have the await.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM