I'm having a strange problem. I have upgraded a Silverlight 5 project to use latest CSLA 4.5. This project uses the old style factories with the EventHandler<DataPortalResult<T>> callback signature.
These work just fine before and after the 4.5 upgrade.
However, if I create a factory using async / await with the FetchAsync dataportal method, it doesn't return the client. Using breakpoints I can confirm that the data portal finished it's work, only it's just as if the response/result that is returned by the data portal doesn't reach back to the client.
The factory that uses the old Silverlight singature still works, it's only the FetchAsync call that doesn't? What could it be?
public static async Task<AssessmentInfoList> GetAsync()
return await DataPortal.FetchAsync<AssessmentInfoList>( new Criteria( ) );
Are you awaiting the call to the new async factory?
The way the WCF infrastructure works in Silverlight, is that the callback from the server is marshalled onto the UI thread by WCF. If the UI thread is blocked, this can't happen and the app basically locks up.
As a result, you _must_ ensure that the call to your factory method is non-blocking. In the case of an async factory method, the calling code _must_ await that call.
Many thanks, Rocky.
My initial attempts at using the async style is somewhat flawed.
As you suspected, my event handler / Caliburn Micro Action had called the factory method without await tried to extract the result of the Factory call, effectively blocking.
By marking that event handler / CM action method as "Async" and awaiting the Factory call, the block was removed and it now works as expected.
Copyright (c) Marimer LLC