Reputation: 547
My understanding is that
await myContext.SaveChangesAsync();
will save the changes, but not allow the thread to continue in the same manner that
myContext.SaveChanges();
behaves.
Is there any difference between these two?
Upvotes: 1
Views: 1439
Reputation: 457157
allow the thread to continue
This is your misunderstanding.
Put simply, synchronous methods like SaveChanges
block the calling thread until the method completes.
Asynchronous methods like SaveChangesAsync
(when consumed with await
) will not block the calling thread. The await
will "pause" the method, but it will not block the thread.
You can find more information about how this works in my async
intro blog post and my post on There Is No Thread.
Upvotes: 3