public static TResult ExecuteWithWriteLock <TResult>(this ReaderWriterLockSlim rwlock, Func <TResult> func)
        {
            TResult result = default(TResult);

            rwlock.ExecuteWithWriteLock(delegate {
                result = func();
            });
            return(result);
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     _disposalLock.ExecuteWithWriteLock(() => {
         _disposed = true;
         _writer.Close();
         _searcher.Close();
         _reader.Close();
         _queue.Dispose();
         if (_commitTimer != null)
         {
             _commitTimer.Cancel();
         }
     });
 }
        internal static IAdoNetProfiler GetProfiler()
        {
            return(_readerWriterLockSlim.ExecuteWithWriteLock(() =>
            {
                if (!_initialized)
                {
                    throw new InvalidOperationException("This factory class has not initialized yet.");
                }

                return _constructor.Invoke();
            }));
        }