/// <inheritdoc/> public TRetType ExecuteLocked <TArgType, TRetType>(TArgType arg, ExecuteLockedDelegate <Local, TArgType, TRetType> handler) { return(locals.ExecuteLocked <TArgType, TRetType>(arg, (tsList, arg2) => handler(this, arg2))); }
/// <summary> /// Locks the list and then calls <paramref name="handler"/>. <paramref name="handler"/> /// must only call <c>*_NoLock()</c> methods. The list is unlocked once this method returns. /// </summary> /// <typeparam name="T">List type</typeparam> /// <typeparam name="TArgType">Argument type</typeparam> /// <typeparam name="TRetType">Return type</typeparam> /// <param name="tsList">A list</param> /// <param name="arg">Passed to <paramref name="handler"/></param> /// <param name="handler">Handler that should execute when the lock is held</param> /// <returns>The value <paramref name="handler"/> returns</returns> public static TRetType ExecuteLocked <T, TArgType, TRetType>(this ThreadSafe.IList <T> tsList, TArgType arg, ExecuteLockedDelegate <T, TArgType, TRetType> handler) { #if THREAD_SAFE return(tsList.ExecuteLocked <TArgType, TRetType>(arg, handler)); #else return(handler(tsList, arg)); #endif }
TRetType ThreadSafe.IList <Parameter> .ExecuteLocked <TArgType, TRetType>(TArgType arg, ExecuteLockedDelegate <Parameter, TArgType, TRetType> handler) { theLock.EnterWriteLock(); try { return(handler(this, arg)); } finally { theLock.ExitWriteLock(); } }
/// <inheritdoc/> public TRetType ExecuteLocked <TArgType, TRetType>(TArgType arg, ExecuteLockedDelegate <TValue, TArgType, TRetType> handler) { theLock.EnterWriteLock(); try { return(handler(this, arg)); } finally { theLock.ExitWriteLock(); } }