1

I want to use TASK for running parallel activities.This task returns a value.How do i use a FUNC inside the task for returning a value?.I get an error at Func.

Task<Row> source = new Task<Row>(Func<Row> Check = () =>
{
    var sFields = (
        from c in XFactory.Slot("IdentifierA")
        where c["SlotID"] == "A100"
        select new
        {
            Field = c["Test"]
        });
});

I change my code to

Task source = Task.Factory.StartNew(() =>
            {
                return 
                (from c in XFactory.Slot("IdentifierA")
                  where c["SlotID"] == "A100"
                   select new
            {
                Field = c["Test"]
            });
            }
            );

1 Answer 1

3

Your basic pattern would look like:

 Task<Row> source = Task.Factory.StartNew<Row>(() => ...; return someRow;  );
 Row row = source.Result; // sync and exception handling
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.