Threading and Concurrency
Through the use of multithreading, CBFS Filter provides powerful concurrency features to help applications maximize their performance. Each component provides the following API members to allow applications to specify the extent to which events should be fired concurrently:
- The SerializeEvents property controls whether events should be serialized on a single worker thread, or fired in parallel on several. By default, this property is disabled, and events are allowed to fire in parallel.
- The MinWorkerThreadCount and MaxWorkerThreadCount configuration settings control the minimum and
maximum number of worker threads the components can use for firing events. By default, both are set to 0, which indicates that a component's system driver should
automatically choose appropriate values based on how many CPU cores the system has.
- Note that these settings are only applicable when SerializeEvents is disabled.
Please note that, even when configured for minimal concurrency, the components always fire events in the context of a worker thread, not in the thread the component was originally created on. Therefore, applications must be sure to synchronize operations between event handlers and other threads as necessary (including, but not limited to, calls to the component instance, unless a method is explicitly documented as callable within events).