Invisible race conditions: The async query

added by DotNetKicks
12/27/2017 3:08:08 PM

1 Kicks, 254 Views

The problem is that this method returns a Task, but it isn't an async method. In other words, we return a task that is still running from ToListAsync, but because we aren't awaiting on it, the session's dispose is going to run, and by the time the server request completes and is ready to actually do something with the data that it go, we are already disposed and we get this error.