Print Page | Close Window

Can't get AsyncSerialTask to work

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1697
Printed Date: 20-Sep-2025 at 11:30pm


Topic: Can't get AsyncSerialTask to work
Posted By: downeytim
Subject: Can't get AsyncSerialTask to work
Date Posted: 25-Mar-2010 at 7:11am
I have tried for several hours to get the examples in the help file for the AsyncSerialTask to work in a unit test.  It does not work.
 
Here is my code. It is take directly from the help file with some minor modification for my database objects
 
CypressEntityManager mgr = CypressEntityManager.DefaultManager;

var rootTask = AsyncSerialTask.Create<string>("Task1");

rootTask
.AddAsyncQuery((code) => mgr.Suffixes.Where(s => s.Code == code))
.AddAsyncQuery( (args) => args.Result.First())
.Execute("Jr", asyncSerCompletedHandler);
}

Here is the first error I get.
Error 203 The type arguments for method 'IdeaBlade.EntityModel.AsyncSerialTaskExtensions.AddAsyncQuery<T0,T1,T2>(IdeaBlade.EntityModel.AsyncSerialTask<T0,T1>, System.Func<T1,IdeaBlade.EntityModel.IEntityQuery<T2>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. 
 
The error is in reference to the first AddAsyncQuery line.  I have tried many different forms of this code and cannot get it working at all.  Unless someone can show me how to do this simple thing I can't see using this as much as I would like to.
 
We need a lot more examples of this type of advanced object in the help or sample applications that use these types of calls in various configurations.
 



Replies:
Posted By: ting
Date Posted: 25-Mar-2010 at 6:18pm
Hi Tim,
 
The "args => args.Result.First()" expression is not a query (which is where the argument mismatch is coming from) and doesn't need to be chained asynchronously.  You can write it without it and just take args.Result.First() in your handler:
 
rootTask
.AddAsyncQuery((code) => mgr.Suffixes.Where(s => s.Code == code))
.Execute("Jr", asyncSerCompletedHandler);  // do args.Result.First() in the handler

You can also write the handler inline with the Execute() if you don't want to define a separate method for it.
 



Print Page | Close Window