Async CSLA Calls -


the 'standard' csla async server calls have typically been structured per following:

base class:

public static void getmyobject(eventhandler<dataportalresult<myobject>> callback) {   var dp = new dataportal<myobject>();   dp.fetchcompleted += callback;   dp.beginfetch(); } 

viewmodel:

protected override void oninitialize(object parameter) {   base.oninitialize(parameter);   base.isbusy = true;   myobject.getmyobject((o, e) => {     if (hasnoexception(e)) {       model = e.object;     }     base.isbusy = false;   }); } 

with new async/await features, format this:

public async static task<myobject> getmyobject() {   return await dataportal.fetchasync<myobject>(); } 

and

protected async override void oninitialize(object parameter) {   base.oninitialize(parameter);   base.isbusy = true;   model = await myobject.getmyobjectasync();   base.isbusy = false; } 

should callback pattern considered deprecated @ point, or still useful ui technologies? when doing new project, i'd rather not have methods in there if can it.

personally, prefer tap methods on callbacks in code.

with microsoft.bcl.async, platforms support async. however, there few situations neither tap nor task available, e.g., windows phone 7.0, .net cf, sl 3. use callbacks if had support 1 of platforms.


Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -