"Pro. Net 4 Parallel Programming in C #" notes
$ periodic scheduled task with
CancellationToken.WaitHandle.WaitOne (TimeSpan)
Feature: If a task is cancel,waitone, it will return immediately.
$ synchronized Meta-select scenario solution serial access Border Zone lock keyword or System.Threading.Monitor or System.Threading.SpinLock increase or decrease value System.Threading.Mutex Synchronous System.Threading.Mutex multiple locks across processes synchronous Threading.WaitHandle.WaitAll () synchronization of all method declarations in a class ([synchronization]) (very heavy) allows multiple readers Read and Write lock
The synchronization element describes the abbreviated form of the lock System.Threading.Monitor, and the heavyweight System.Threading.Barrier sets the signal quantity in advance and continues execution after sufficient semaphore. Automatic reset System.Threading.CountdownEvent similar to barrier, but requires active reset System.Threading.ManualResetEventSlim similar to Countdownevent, But without setting the semaphore number, once set, all waiting threads are freed System.Threading.AutoResetEvent like ManualResetEventSlim, but automatically reset, each time set releases only one waiting thread, Cannot use CancellationToken to wait, does not guarantee which thread is released System.Threading.SemaphoreSlim resembles AutoResetEvent, also does not guarantee which thread is released, However, you can specify the number of threads to release per set, and you can wait with CancellationToken
$ taskscheduler is used to specify which thread executes the task and the number and order of concurrent tasks
The use of thread local Storage (tls,parallel.for) reduces access to competing data and improves performance by accessing only at the end of each branch path.
$ when the operation is simple, you can reduce the overhead of calling a delegate (delegate) by specifying the block mode (chunking partitioner) of the data.