CSLA 4.5 - Local Command Execution in Silverlight with asynchronous operation within DataPortal_Execute

CSLA 4.5 - Local Command Execution in Silverlight with asynchronous operation within DataPortal_Execute

Old forum URL: forums.lhotka.net/forums/t/11618.aspx


skagen00 posted on Wednesday, October 03, 2012

We have a command BO in Silverlight that is configured to RunLocal, and the actions within this command are asynchronous.

We do this because we're calling out to a third party with a fair amount of network traffic and processing involved, and we wanted the client to shoulder the burden rather than have the web server shoulder the burden.

At present, it doesn't look like there is a place with the refactored dataportal to allow this to happen.  The pre CSLA 4.5 code looks like this:

public void DataPortal_Execute(Csla.DataPortalClient.LocalProxy<OurCommandObjectType>.CompletedHandler handler)
{
   // Call a third party asynchronously,
   // invoking handler when completed.
}

Any suggestions?

skagen00 replied on Wednesday, October 03, 2012

By the way, it was great seeing you give the keynote yesterday.  You're always a great speaker to come and see.

RockfordLhotka replied on Wednesday, October 03, 2012

You should be able to mark the data portal method as async. For example:

[RunLocal]
private async Task DataPortal_Fetch()
{
  // use await keyword in here
}

 

RockfordLhotka replied on Wednesday, October 03, 2012

You will need to learn the task parallel library patterns used to wrap "old style" async code, because most of the existing SL APIs use the older callback handler model.

Copyright (c) Marimer LLC