Project Description

The Silverlight Continuation Tasks Library provides a simplification to chain a continuation of asynchronous tasks, on completion, to invoke a second task ... one after another to any arbitrary length. The purpose of this library is to reduce Silverlight code from verbose asynchronous callback event handling.

Quick Samples

  • TaskQueue Class
Namespace: ContinuationTasks
Example:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using ContinuationTasks;

namespace MySilverlightApp1.Views
{
    public partial class MyPage1 : Page
    {
        private TaskQueue _DelayReloader;

        public MyPage1()
        {
            InitializeComponent();

            _DelayReloader = new TaskQueue();
            _DelayReloader.AddTask(() => { domainDataSource1.Load(); }, 100,
                                   () => domainDataSource1.CanLoad, 10);
            _DelayReloader.AddTask(() => { domainDataSource2.Load(); }, 100,
                                   () => domainDataSource2.CanLoad, 10);
            _DelayReloader.AddTask(() => { domainDataSource3.Load(); }, 100,
                                   () => domainDataSource3.CanLoad, 10);
            ...
        }

        private void btnApply_Click(object sender, RoutedEventArgs e)
        {
            ...
                _DelayReloader.Start(true);
            ...
        }
    }
}
  • ContinuationEntities<T> Class
Namespace: ContinuationTasks.RIA_Client
This class further encapsulates continuations specially for RIA Services client to submit a set of Entities' changes in sequence.
Example:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using ContinuationTasks;
using ContinuationTasks.RIA_Client;

namespace MySilverlightApp1.Views
{
    public partial class MyPage2 : Page
    {
        private ContinuationEntities<MyDomainContext> _ContContext;
        private ContinuationEntities<MyDomainContext> ContContext
        {
            get
            {
                if (_ContContext == null)
                    _ContContext = new ContinuationEntities<MyDomainContext>
                                       (myDomainContext, 50);
                return _ContContext;
            }
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            submittingBusyIndicator.IsBusy = true;
            ...
            ContContext.SubmitEntities(myEntityCollection,
                op => { op.HandleSubmittedError(); },
                () => { _DelayReloader.Start(true);
                        submittingBusyIndicator.IsBusy = false; });
            ...
        }
    }
}

Last edited Dec 20, 2012 at 5:00 AM by AbelCheng, version 18