Skip to content

LINQ AsyncPredicateExtensions

ZZZ Projects edited this page Jan 24, 2016 · 3 revisions

Async Predicate extension methods allow to perform operation using an async predicate on LINQ to objects asynchronously.

Support:

  • OrderByPredicateCompletion
  • StartPredicateConcurrently
// Using Z.Linq

public Task<IEnumerable<Customer>> MyAsyncTaskMethod(CancellationToken cancellationToken)
{
    List<Customer> customers = DB.GetCustomers();
    
    // GET all customers by predicate completion
    var task = list.WhereAsync(c => MyAsyncPredicate(DB.IsCustomerActiveAsync(c)))
                   .OrderByPredicateCompletion();

    // ... synchronous code ...
    
    return task;
}

LinqAsyncManager

Default value to use can be modified in the LinqAsyncManager

LinqAsyncManager.DefautlValue.OrderByPredicateCompletion = true; // default false;
LinqAsyncManager.DefaultValue.StartPredicateConcurrently = false; // default false;