Tham khảo tài liệu 'visual c# 2010 recipes solution_7', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 15 PARALLEL PROGRAMMING requested became available this example waits for all of the tasks to complete before obtaining the results. using System using using namespace Recipe15_03 . class Recipe15_03 . static void Main string args Press enter to start Create the tasks. Task int task1 Task int . writeDays Task int task2 Task int . writeMonths Task int task3 Task int . writeCities Wait for all of the tasks to complete. task1 task2 task3 Get the results and write them out. 0 days were written 0 months were written 0 cities were written Wait to continue. nMain method complete. Press Enter static int writeDays . . . . string daysArray Monday Tuesday Wednesday Thursday Friday Saturday Sunday foreach string day in daysArray . . . Day of the Week 0 day 500 . . return 735 CHAPTER 15 PARALLEL PROGRAMMING static int writeMonths string monthsArray Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec foreach string month in monthsArray . . Month 0 month 500 . return static int writeCities . string citiesArray London New York Paris Tokyo Sydney foreach string city in citiesArray . . . City 0 city 500 . . return 15-4. Parallel Process a Collection Problem You need to parallel process each element in a collection. Solution Use the method to create a new task to process each of the elements in a collection. Optionally use to limit the degree of parallelism that will be used. How It Works The static method accepts a collection a function delegate and an optional instance of ParallelOptions as