Parallel Task
The Parallel Task pattern is conceptually very simple – it runs the same code on multiple background threads. As with almost all other OTL high-level patterns, a new instance is created by calling the appropriate factory function – in this case, that is Parallel.ParallelTask
, which returns an IOmniParallelTask
interface. Similar to most OTL patterns, it implements functionality to catch and report exceptions, features a cancellation mechanism, and most importantly for our example, triggers a notification method when the last background worker stops execution.
A parallel task was designed to speed up a longer operation without having to deal with background threads, notifications, and so on. Because of that, by default it works in blocking mode, just like the Join pattern. Similarly, we can call NoWait
on the interface and turn it into an asynchronous pattern.
To demonstrate the pattern – and a few other OTL-specific features – I have...