Async, RIA Service with Microsoft AsyncTargetingPack

34 Views Asked by At

I have installed the Microsoft AsyncTargetingPack in order to use async/await in specific RIA invoke operations. I also read a lot about the implementation and some articls about building extensions for RIA data source from Kyle McClellan & Oren Beeri[Using the new Async framework with RIA][1][1]: https://zormim.wordpress.com/2011/01/06/using-the-new-async-framework-with-ria/

I used his extension as follows: This async method will await the RIA invoke method to return the result to the caller either true / false.

public async Task<bool> CheckAccountDuplicates(string name, string id)
{
bool ret = false;
Debug.WriteLine("In func");
ret = await Context.InvokeAsync(() => Context.AccountNameExists(name, id));
Debug.WriteLine(ret);
return ret;
}

The caller is another method as follows:

public bool SaveRecs(ObservableCollection<Acc> accList)
{
    int i = 0;

    foreach (Acc item in accList)
    {
        if (CheckAccountDuplicates(item.name, item.id)) continue;
        item.id = MaxID + i;
        Context.Accs.Add(item);
        i++;
    }
    return Commit();
}

as you can see this method needs to make sure that Acc 'name' does not exist before attempting to add it to the context.

The problem is that the debug write the value "In Func" once and the application halts ...!!! no response at all.

What am I doing wrong ??

0

There are 0 best solutions below