Hi,
I'm having an issue when I'm using the Async dataPortal methods (FetchAsync(), etc...) at the same time as using a Local Server DataPortal
public async Task Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
{
if (isSync || Csla.ApplicationContext.LogicalExecutionLocation == ApplicationContext.LogicalExecutionLocations.Server)
{
return await _portal.Fetch(objectType, criteria, context, isSync);
}
else
{
var tcs = new TaskCompletionSource();
var bw = new Csla.Threading.BackgroundWorker();
bw.DoWork += (s, o) =>
{
o.Result = _portal.Fetch(objectType, criteria, context, isSync).Result;
};
bw.RunWorkerCompleted += (s, o) =>
{
if (o.Error == null)
tcs.TrySetResult((DataPortalResult)o.Result);
else
tcs.TrySetException(o.Error);
};
bw.RunWorkerAsync();
return await tcs.Task;
}
}
In my case I'm always falling the in "else" block which seems to dead lock on the ".Result" which for some reason never completes
I just don't get the else block and why this method cannot use the code inside the "if" block all the time.
When I change the code to always enter the "if" block no more dead lock.
Discussion around this question is in GitHub here: https://github.com/MarimerLLC/csla/issues/300
Copyright (c) Marimer LLC