Hi Denis,
Here it is:
var taskSistema =
DataRepository.ExecuteQueryTaskAsync(DataRepository.GetQuery<Sistema>());
taskSistema.Wait();
var taskRevendas =
DataRepository.ExecuteQueryTaskAsync(DataRepository.GetQuery<Revenda>());
taskRevendas.Wait();
var taskFornecedores =
DataRepository.ExecuteQueryTaskAsync(DataRepository.GetQuery<Fornecedor>());
taskFornecedores.Wait();
var taskTransportadoras =
DataRepository.ExecuteQueryTaskAsync(DataRepository.GetQuery<Transportadora>());
taskTransportadoras.Wait();
And the
respective DataRepository methods:
public IQueryable<T> GetQuery<T>() where T : Entity
{
return Manager.GetQuery<T>();
}
public Task<List<T>> ExecuteQueryTaskAsync<T>(IQueryable<T>
query) where T : Entity
{
var tcs = new
TaskCompletionSource<List<T>>();
Task.Factory.StartNew(() =>
{
Manager.ExecuteQueryAsync((EntityQuery<T>) query, operation =>
{
if (operation.CompletedSuccessfully)
tcs.SetResult(operation.Results.ToList());
else
{
operation.MarkErrorAsHandled();
tcs.SetException(operation.Error);
}
});
});
return tcs.Task;
}
Examining the code I now see that the Manager.ExecuteQueryAsync doesn´t
need to be inside the Task.Factory.StartNew. So I made the change but the issue
is still present. Any ideas?