IdeaBlade DevForce 2010 Help Reference
Start(Func<CoroutineOperation,IEnumerable<Func<INotifyCompleted>>>,Action<CoroutineOperation>) Method
See Also  Example Send Feedback
IdeaBlade.EntityModel Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class > Start Method : Start(Func<CoroutineOperation,IEnumerable<Func<INotifyCompleted>>>,Action<CoroutineOperation>) Method



asyncFns
List of asynchronous functions
completedHandler
Optional completion handle
Start serial execution of multiple asynchronous actions.

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function Start( _
   ByVal asyncFns As Func(Of CoroutineOperation,IEnumerable(Of Func(Of INotifyCompleted))), _
   Optional ByVal completedHandler As Action(Of CoroutineOperation) _
) As CoroutineOperation
Visual Basic (Usage)Copy Code
Dim asyncFns As Func(Of CoroutineOperation,IEnumerable(Of Func(Of INotifyCompleted)))
Dim completedHandler As Action(Of CoroutineOperation)
Dim value As CoroutineOperation
 
value = Coroutine.Start(asyncFns, completedHandler)

Parameters

asyncFns
List of asynchronous functions
completedHandler
Optional completion handle

Return Value

A CoroutineOperation representing this operation

Example

Visual BasicCopy Code
Public Sub CoroutineSample4()
    Dim mgr = New NorthwindIBEntities()
    Dim op = Coroutine.Start(Function(coop As CoroutineOperation) Sample3Actions(coop, mgr))
    AddHandler op.Completed, Sub(s As Object, e As CoroutineCompletedEventArgs)
                                 If e.CompletedSuccessfully Then
                                     MessageBox.Show("OK")
                                 End If
                             End Sub
End Sub

Private Function Sample3Actions(ByVal coop As CoroutineOperation, ByVal mgr As NorthwindIBEntities) As IEnumerable(Of Func(Of INotifyCompleted))
    ' Setup of the list of async functions for the Coroutine to execute serially.
    Dim operationList = New List(Of Func(Of INotifyCompleted))

    Dim f1 As Func(Of INotifyCompleted) = Function() mgr.Customers.Take(2).ExecuteAsync()
    operationList.Add(f1)

    Dim f2 As Func(Of INotifyCompleted) =
         Function()
             ' Use the results from the first async query. 
             Dim firstOp = DirectCast(coop.Notifications.First(), EntityQueryOperation(Of Customer))
             Dim customers = firstOp.Results
             Dim cityList = New List(Of String)
             customers.ForEach(Sub(cust As Customer) cityList.Add(cust.City))
             Dim pd = New IdeaBlade.Linq.PredicateDescription(GetType(Order), "Shipcity", IdeaBlade.Linq.FilterOperator.InList, cityList)
             Return mgr.Orders.Where(pd).ExecuteAsync()
         End Function
    operationList.Add(f2)

    Return operationList
End Function

Remarks

Used to start serial execution of a list of asynchronous actions. Instead of passing an iterator block, pass an IEnumerable of the asynchronous functions to be executed. Asynchronous functions in the list will be executed serially.

Use this overload of the Start method when your iterator accepts a CoroutineOperation as an argument. You can use the CoroutineOperation to track the prior operations within the function list.

This overload of the Start method is useful in Visual Basic, where iterators are not supported.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.