Asynchronous operations outside of Silverlight

Asynchronous operations outside of Silverlight

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


vdhant posted on Wednesday, October 29, 2008

I am assuming the answer is yes, but I just wanted to confirm.

Is there anything stopping you from making asynchronous calls through the data portal outside of silverlight. For instance, if I have a normal WPF application and want to make an asynchronous request on a Business Object, can i use the asynchronous operations plumbing? If so, is this advisable or am I best to handle the asynchronous operations manually. As i said i think the answer is yes, but i just wanted to check.

Also just wanted to check if the MobileObject infrastructure was put in place just for silverlight?

Cheers
Anthony

sergeyb replied on Thursday, October 30, 2008

Sure, you can.  Asynchronous data portal can be used anywhere now, in WPF, WInForm or WebForms.  The question really is do you have a scenario where you have an advantage of doing so?  Typically, your forms would load faster, but the user cannot use them until the data is fully loaded.  You can Save calls asynchronously as well, but you need to have a real good strategy of handling errors from those calls, because the user can close the form before save is actually completed, and then you have a problem…  Where they are extremely useful is in enabling you to provide animation for long running fetch or save operations because your UI thread is free to do whatever since portal calls are executing on background thread.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: vdhant [mailto:cslanet@lhotka.net]
Sent: Wednesday, October 29, 2008 11:54 PM
To: Sergey Barskiy
Subject: [CSLA .NET] Asynchronous operations outside of Silverlight

 

I am assuming the answer is yes, but I just wanted to confirm.

Is there anything stopping you from making asynchronous calls through the data portal outside of silverlight. For instance, if I have a normal WPF application and want to make an asynchronous request on a Business Object, can i use the asynchronous operations plumbing? If so, is this advisable or am I best to handle the asynchronous operations manually.

As i said i think the answer is yes, but i just wanted to check.
Cheers
Anthony


ajj3085 replied on Thursday, October 30, 2008

I think the answer is, "yes, there are a few good reasons."

The forms loading faster provide a better user experience, making over-all time seem to be shorter.

As for saving, it's easy to stop the form from closing while an async operation is running; I always do my saves in the background.  It allows you to disable the controls, and actually have the user see it's disabled, and Windows doesn't think your program has become unresponsive. 

In Windows forms this is fairly easy; use a Background worker.  Unbind your UI as normal, disable the controls, and start the background worker.  Your DoWork handler just does the save.  In ProcessCompleted, check for error and handle appropriately, and rebind the UI.  Then, just override OnClosing and set e.Cancel = saveWorker.IsRunning.  The user won't be able to close the window.  You could also display a message explaining to the user why they can't close the window.

I really recommend it. 

It's harder to do this in Wpf though; impossible actually if you're using CslaDataProvider, because Saving doesn't honor the IsAsync setting.  I have modified it actually to do so, but I haven't tested it enough yet, but it appears to work.

Well, enough of my ranting. Big Smile [:D]

vdhant replied on Thursday, October 30, 2008

Cheers and thanks for the replies.
Anthony

Copyright (c) Marimer LLC