Skip to content

Commit 1084815

Browse files
authored
Update README.md
1 parent d724b95 commit 1084815

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,20 @@ the recommended usage of Transaction Scope by calling `.AcquireAppLockAsync(...)
122122
```
123123
#### Using Sql Connection (Session Scope will be used) - Without Exception Handling:
124124
_*NOTE: *Application Lock should ALWAYS be explicity Disposed of to ensure Lock is released**_
125+
As a Connection level lock this will use the Sql Server Session level scoping which has it's own set of pros/cons and
126+
potentially some additional risks of orphaned locks in the event of a thread crasching and not disposing correctly or
127+
returning to the connection pool for the Session to end.
128+
129+
For more info see the [Microsoft Docs here](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-getapplock-transact-sql?view=sql-server-ver16#remarks):
130+
https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-getapplock-transact-sql?view=sql-server-ver16#remarks
131+
125132
```csharp
126133
await using var sqlConn = new SqlConnection(sqlConnectionString);
127134
await sqlConn.OpenAsync();
128135

129-
//Using any SqlTransaction (cast DbTransaction to SqlTransaction if needed), this will
130-
// attempt to acquire a distributed mutex/lock, and will wait up to 5 seconds before timing out.
136+
//Using any SqlConnection (cast DbConnection to SqlConnection if needed), this will
137+
// attempt to acquire a distributed mutex/lock at the connection level, and will wait
138+
// up to 5 seconds before timing out (as specified).
131139
//Note: Default behavior is to throw and exception but this is controlled via throwsException param
132140
// and can then be managed via the returned the SqlServerAppLock result.
133141
//Note: The IDisposable/IAsyncDisposable implementation ensures that the Lock is released!

0 commit comments

Comments
 (0)