Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Threading Namespace / Threading­Services Class / Threading­Services Methods / Threading­Services.​With­Concurrency­Controller Method

ThreadingServices.WithConcurrencyController Method

Sets the ambient concurrency controller for the current thread. Until the returned AmbientConcurrencyControllerContext value is disposed, thread-aware objects created in the current thread will be assigned to the given concurrency controller.

Namespace:  PostSharp.Patterns.Threading
Assembly:  PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 5.1.3.0 (5.1.3.0)
Syntax
C#
public static AmbientConcurrencyControllerContext WithConcurrencyController(
	IConcurrencyController concurrencyController
)

Parameters

concurrencyController
Type: PostSharp.Patterns.Threading.IConcurrencyController
The ambient concurrency controller. Use the ConcurrencyControllerFactory class to create new concurrency controllers.

Return Value

Type: AmbientConcurrencyControllerContext
A IDisposable value representing the ambient concurrency controller context.
Remarks
This method can be used to optimize performance when creating a large tree of thread-aware objects that need to share the same concurrency controller.
See Also