LoadOperation.Completed called before executing request

61 views Asked by At

I use LoadOperation everywhere in my code to retrieve informations from server. But for one of them the Completed event is called before the request is executed on server (I just put breakpoints to see it). And then the Entities list that should be returned is empty.

The code is very common and the same query is called in another function of the same class with success :

domain.Load(domain.GetItemsByIDQuery(parentID), (m) =>
            {
                var v= m.Entities.First(); // crash because m.Entities is empty
            }, null);

Any clue on what can happen since I can't see any difference between this call to LoadOperation and the others that are working.

Thanks for your help

edit: After a lot of tries I've found that not setting a property binded to the BusyIndicator visibility makes the problem to vanish... There must be a deeper reason for this error ! If someone have an idea ?

1

There are 1 answers

2
Christian Amado On

Maybe you must apply some changes to avoid crashing:

domain.Load(domain.GetItemsByIDQuery(parentID), m =>
{
    if (!m.HasError)
    {
        if (m.Entities != null)
        {
            var v = m.Entities.First(); 
        }
    }   
    else
    {
        //Catch errors here.
    } 
}, null);