2

I need to use entity framework to query many databases at once, but I want all the queries to happen at the same time, and for me to be notified when it has all completed.

I have been using the Task Parallel Library and thought may be that can be used to achieve this... by firing off each task in a loop, changing the connection string in each iteration so it would hit a different db. However, in my experience of task parallel library you only know when each individual task has completed and not a batch.

I am working in an MVC web environment not WPF.

1
  • 3
    Can you use VS2012 (i.e. C# 5.0)? Also, you might want to have a look at methods like Task.WaitAll(). Commented Feb 3, 2013 at 12:50

1 Answer 1

1

If you are using something like.

Task myTask = task.Factory.StartNew( () => {
        some code
} );

Task myTask2 = task.Factory.StartNew( () => {
        some code again
} );

then you use the wait method.

myTask.Wait();
myTask2.Wait();

which will not pass until both tasks are complete.

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.