Multithreading vs Parallelism. Multithreading is easy, just call Thread.start(). It is primarily used to keep the ui responsive.Parallel programming is used to maximally use the cores that are available.
The ray traces sample comes form the parallel extensions.
Ingo shows a demo walking a large tree structure and visualizing this. The first version uses no threading and takes about 1500 ms to complete. In the second version he tries to make a thread for every node. This version blows up, every thread takes up one mb of memory. The third version uses Threadpool.QueueUeserWorkitem, timing is off now because the threads are fire and forget. The fourth version works with the new tasks from the parallel extensions. This version does the work in about 800ms.
More functionality of the Task is making the creation possible using a factory (shorter, cleaner code). Also the results of a task can be simply used, all synchronization is done for you. In the demo he sums up all values in the tree without having to worry about synchronisation.
After that my netbook just closed down. Basically Ingo covered three ways to do parallel programming in C# 4.0.
- Fine-Grained Parallelism: Task-API and coordination structures (the foundation of it all)
- Structured Parallelism: Parallel
- Declarative Parallelism: PLINQ
Ingo is a great speaker and made this last session while everybody was tired still fun.