SCLoader/InstanceLock.cs
/// <summary>
/// Sets the instance lock in the specified storage
/// Waits for an existing lock to be released or timed out
/// </summary>
/// <param name="onLockAppliedCallback">Action is called after the lock was applied</param>
Sets the instance lock in the specified storage
Waits for an existing lock to be released or timed out
Sets the instance lock in the specified storage Waits for an existing lock to be released or timed out
public void ApplyAsync(Action onLockAppliedCallback)
        {
            this.OnLockAppliedCallback = onLockAppliedCallback;
            this.lockApplyTask = new Task((state) =>
            {
                try
                {
                    ApplyLockTask(state).Wait();
                }
                catch (AggregateException ex)
                {
                    ex.Handle((innerEx) =>
                    {
                        return innerEx is TaskCanceledException;
                    });
                }
            }, this, this.CancellationTokenSource.Token);
            this.lockApplyTask.ContinueWith((task) =>
            {
                if (task.Exception != null)
                {
                    var instance = (InstanceLock)task.AsyncState;
                    instance.Logger.LogException("Failed to apply InstanceLock. See exception for details.", task.Exception);
                }
            });
            this.lockApplyTask.Start();
        }
public void ApplyAsync ( Action onLockAppliedCallback ) { this . OnLockAppliedCallback = onLockAppliedCallback ; this . lockApplyTask = new Task ( ( state ) => { try { ApplyLockTask ( state ) . Wait ( ) ; } catch ( AggregateException ex ) { ex . Handle ( ( innerEx ) => { return innerEx is TaskCanceledException ; } ) ; } } , this , this . CancellationTokenSource . Token ) ; this . lockApplyTask . ContinueWith ( ( task ) => { if ( task . Exception != null ) { var instance = ( InstanceLock ) task . AsyncState ; instance . Logger . LogException ( " " , task . Exception ) ; } } ) ; this . lockApplyTask . Start ( ) ; }
Sets the instance lock in the specified storage
Waits for an existing lock to be released or timed out
Sets the instance lock in the specified storage Waits for an existing lock to be released or timed out
// Mark the exception thrown by an CancellationToken as handled // Check if the Task crashed with an exception // The state object is an instance of the current class
onLockAppliedCallback
Action
Action is called after the lock was applied
Action is called after the lock was applied