• Performance
  • API Documentation
  • Source Code
Show / Hide Table of Contents
  • InSync
    • AsyncSynchronized
    • AsyncSynchronized<T>
    • GuardedValue<T>
    • IAsyncSynchronized<T>
    • IBareAsyncLock
    • IBareAsyncLock<T>
    • IBareLock
    • IBareLock<T>
    • ISynchronized<T>
    • LockException
    • MultiSync
    • ReaderSynchronized<TRead>
    • ReaderWriterSynchronized<T>
    • ReaderWriterSynchronized<TWrite, TRead>
    • ReaderWriterSynchronizedFactory
    • Synchronized
    • Synchronized<T>
    • TimingMethod
    • UnlockException
    • UpgradeableReaderSynchronized<TRead>
    • ValueContainer<T>

Interface IAsyncSynchronized<T>

Allows its protected object to be accessed only after a synchronization begins. Its methods automatically complete synchronizations or provide some means to do so. They properly handle exceptions thrown by starts of synchronization or users' operations.

Various asynchronous operations are supported. The protected object is non-null.

Namespace: InSync
Assembly: InSync.dll
Syntax
public interface IAsyncSynchronized<T>
    where T : class
Type Parameters
Name Description
T

The type of the protected object.

Methods

LockAsync()

Asynchronously locks and returns a guard to allow access of the protected object and unlocking.

Declaration
Task<GuardedValue<T>> LockAsync()
Returns
Type Description
Task<GuardedValue<T>>
Exceptions
Type Condition
LockException

LockAsync(CancellationToken)

Asynchronously locks and returns a guard to allow access of the protected object and unlocking.

Declaration
Task<GuardedValue<T>> LockAsync(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task<GuardedValue<T>>
Exceptions
Type Condition
LockException

WithLockAsync(Action<T>)

Asynchronously locks, performs the action on the captured context or task scheduler (if any) then unlocks. If the action throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Action<T> action)
Parameters
Type Name Description
Action<T> action

The protected object is supplied as the argument of the action

Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Action<T>, CancellationToken)

Asynchronously locks, performs the action on the captured context or task scheduler (if any) then unlocks. If the function throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Action<T> action, CancellationToken cancellationToken)
Parameters
Type Name Description
Action<T> action

The protected object is supplied as the argument of the action

CancellationToken cancellationToken
Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Action<T>, CancellationToken, Boolean)

Asynchronously locks, synchronously performs the action then unlocks. If the function throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Action<T> action, CancellationToken cancellationToken, bool onCapturedContext)
Parameters
Type Name Description
Action<T> action

The protected object is supplied as the argument of the action

CancellationToken cancellationToken
System.Boolean onCapturedContext

true to perform the action on the original context or task scheduler if there is a context.

Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Action<T>, Boolean)

Asynchronously locks, performs the action then unlocks. If the action throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Action<T> action, bool onCapturedContext)
Parameters
Type Name Description
Action<T> action

The protected object is supplied as the argument of the action

System.Boolean onCapturedContext

true to perform the action on the original context or task scheduler if there is a context.

Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Func<T, Task>)

Asynchronously locks, performs the action on the captured context or task scheduler (if any) then unlocks. If the action throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Func<T, Task> asyncAction)
Parameters
Type Name Description
Func<T, Task> asyncAction

The protected object is supplied as the argument of the action

Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Func<T, Task>, CancellationToken)

Asynchronously locks, performs the action on the captured context or task scheduler (if any) then unlocks. If the action throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Func<T, Task> asyncAction, CancellationToken cancellationToken)
Parameters
Type Name Description
Func<T, Task> asyncAction

The protected object is supplied as the argument of the action

CancellationToken cancellationToken
Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Func<T, Task>, CancellationToken, Boolean)

Asynchronously locks, performs the action then unlocks. If the action throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Func<T, Task> asyncAction, CancellationToken cancellationToken, bool onCapturedContext)
Parameters
Type Name Description
Func<T, Task> asyncAction

The protected object is supplied as the argument of the action

CancellationToken cancellationToken
System.Boolean onCapturedContext

true to perform the action on the original context or task scheduler if there is a context.

Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync(Func<T, Task>, Boolean)

Asynchronously locks, performs the action then unlocks. If the action throws an exception, the lock is released automatically.

Declaration
Task WithLockAsync(Func<T, Task> asyncAction, bool onCapturedContext)
Parameters
Type Name Description
Func<T, Task> asyncAction

The protected object is supplied as the argument of the action

System.Boolean onCapturedContext

true to perform the action on the original context or task scheduler if there is a context.

Returns
Type Description
Task
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, TResult>)

Asynchronously locks, calls the function on the captured context or task scheduler (if any) then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, TResult> func)
Parameters
Type Name Description
Func<T, TResult> func

The protected object is supplied as the argument of the function. The returned value is returned by this method.

Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, TResult>, CancellationToken)

Asynchronously locks, calls the function on the captured context or task scheduler (if any) then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, TResult> func, CancellationToken cancellationToken)
Parameters
Type Name Description
Func<T, TResult> func

The protected object is supplied as the argument of the function. The returned value is returned by this method.

CancellationToken cancellationToken
Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, TResult>, CancellationToken, Boolean)

Asynchronously locks, synchronously calls the function then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, TResult> func, CancellationToken cancellationToken, bool onCapturedContext)
Parameters
Type Name Description
Func<T, TResult> func

The protected object is supplied as the argument of the function. The returned value is returned by this method.

CancellationToken cancellationToken
System.Boolean onCapturedContext

true to call the function on the original context or task scheduler if there is a context.

Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, TResult>, Boolean)

Asynchronously locks, calls the function then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, TResult> func, bool onCapturedContext)
Parameters
Type Name Description
Func<T, TResult> func

The protected object is supplied as the argument of the function. The returned value is returned by this method.

System.Boolean onCapturedContext

true to calls the function on the original context or task scheduler if there is a context.

Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, Task<TResult>>)

Asynchronously locks, calls the function on the captured context or task scheduler (if any) then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, Task<TResult>> asyncFunc)
Parameters
Type Name Description
Func<T, Task<TResult>> asyncFunc

The protected object is supplied as the argument of the function. The returned value is returned by this method.

Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, Task<TResult>>, CancellationToken)

Asynchronously locks, calls the function on the captured context or task scheduler (if any) then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, Task<TResult>> asyncFunc, CancellationToken cancellationToken)
Parameters
Type Name Description
Func<T, Task<TResult>> asyncFunc

The protected object is supplied as the argument of the function. The returned value is returned by this method.

CancellationToken cancellationToken
Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, Task<TResult>>, CancellationToken, Boolean)

Asynchronously locks, calls the function then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, Task<TResult>> asyncFunc, CancellationToken cancellationToken, bool onCapturedContext)
Parameters
Type Name Description
Func<T, Task<TResult>> asyncFunc

The protected object is supplied as the argument of the function. The returned value is returned by this method.

CancellationToken cancellationToken
System.Boolean onCapturedContext

true to call the function on the original context or task scheduler if there is a context.

Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException

WithLockAsync<TResult>(Func<T, Task<TResult>>, Boolean)

Asynchronously locks, calls the function then unlocks. The returned value from the function is returned. If the function throws an exception, the lock is released automatically.

Declaration
Task<TResult> WithLockAsync<TResult>(Func<T, Task<TResult>> asyncFunc, bool onCapturedContext)
Parameters
Type Name Description
Func<T, Task<TResult>> asyncFunc

The protected object is supplied as the argument of the function. The returned value is returned by this method.

System.Boolean onCapturedContext

true to call the function on the original context or task scheduler if there is a context.

Returns
Type Description
Task<TResult>
Type Parameters
Name Description
TResult
Exceptions
Type Condition
LockException
UnlockException
In This Article
Back to top Generated by DocFX