I have the following method running in a non-GUI thread within my application:
private async Task PerformContextSubmitAsync()
{
try
{
await DataContextProvider.GetDefaultContext().SaveChangesAsync();
}
catch (Exception ex)
{
Log.Error("Error performing context submit", ex);
}
}
Which is called like this:
await PerformContextSubmitAsync();
The application is a WPF/Prism based application so I'm also publishing events to update a progress bar and file count in the GUI such as:
_eventAggregator.GetEvent<DatabaseProgressEvent>().Publish(new DatabaseProgress(percentDone));
Everything works as expected accept I'm still seeing a "chunking" effect in the UI updates that coincide with the call to SaveChangesAsync()
.
Basically this is still blocking the thread that this is being executed on. Is this a limitation of SQL Server CE or am I doing something really stupid?
I can find precious little about this searching Google and nothing on SO.
After some more testing it appears that I shouldn't be using the
await
keyword in he call to theasync
method.Executing the call like this:
Doesn't block the original calling thread, but it doesn't seem to actually execute in an asynchronous fashion. It seem to behave more like deferring the execution to a point of time in the future.