ILNumerics Ultimate VS

SettingsEnsureT Method (ExpressionFuncT, T)

ILNumerics Ultimate VS Documentation
ILNumerics - Technical Application Development
Ensure the value for a specific (static) setting with robust rollback. This should be used in a 'using' directive.

[ILNumerics Core Module]

Namespace:  ILNumerics
Assembly:  ILNumerics.Core (in ILNumerics.Core.dll) Version: (5.5.7503.3146)

public static IDisposable Ensure<T>(
	Expression<Func<T>> p,
	T v
where T : struct, new()


Type: System.Linq.ExpressionsExpressionFuncT
Lambda expression _reading_ the target property.
Type: T
The value to be ensured for settings.

Type Parameters

Type of the settings value.

Return Value

Type: IDisposable
IDisposable which resets the setting property to its original value when Dispose is called.

Here is how this function is to be used:
  • Enclose the instructions where a certain value for one of the ILNumerics settings is needed into an 'using' block.
  • In the head of the 'using' the EnsureT(ExpressionFuncT, T) method is called with a lambda function wrapping the setting to control and the new value for it.
  • During the execution of the instructions in the body of the 'using' block the property will have the value provided by v.
  • Once the body of the 'using' block is left the value of the Settings property will be reset to its original value automatically.

[ILNumerics Core Module]


<code>using (Settings.Ensure(() => Settings.MaxNumberThreads, 1u)) { //this part runs in single threaded mode // // ... } // here we continue with Settings.MaxNumberThreads set to the original value, before we had modified it. </code>
See Also