type ConversionErrorType2 = ResizeArray<string>
let openSqlConnection (settings: Settings): Result<SqlConnection, ConversionErrorType2> =
try
Ok (createAndOpenConnection settings.DestServerName settings.DestDbName)
with
| ex ->
Error ([genericAppErrorMsg ex] |> ResizeArray)
....
let processResult = result {
use! cn = openSqlConnection settings
return! getImportColumns cn settings
>>= parseCsv settings
>>= importData cn settings.DestSqlTableName
}
result is a computation expression defined in the library. I didn’t include all the code but that is not important.
My question is related to use!. I had to load about 700 csv files and eventually the connection pool ran out of connections which means that use! doesn’t do what I thought it should do, i.e. release the connection when the computation block is done.
It says that: “It [the use keyword] provides the same functionality as a let binding but adds a call to Dispose on the value when the value goes out of scope.”
Unfortunately I have no idea if there is some kind of internal maximum number for disposables and/or file connections. (I’ve posted this more as a jumping-off point for people who come here wondering what use does.)