using Function

A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose' is called on the resource no matter if the func returns or throws. If func returns, the return value of this function is equal to return value of func. If func throws, this function also throws (after disposing the resource).

using<T extends IDisposable, TResult>(resources: T extends IDisposable | T extends IDisposable[], func: (...r: T extends IDisposable[]) => TResult): TResult

Parameter Type Description
resources T extends IDisposable | T extends IDisposable[]  
func (...r: T extends IDisposable[]) => TResult  

Returns - TResult

Defined in

Last Updated: 13 June, 2024