public void Setup()
        {
            _lock     = new LockMethod();
            _lockFree = new LockFreeMethod();

            // Keep benchmarks consistent
            ThreadPool.SetMinThreads(Environment.ProcessorCount, Environment.ProcessorCount);
            ThreadPool.SetMaxThreads(Environment.ProcessorCount, Environment.ProcessorCount);
        }
Exemple #2
0
        public bool TryLock(int x, int y, int width, int height, out WICBitmapLock wicImageLock)
        {
            Int32Rect lockRect = new Int32Rect(x, y, width, height);

            object[] args   = new object[] { _wicBitmap, lockRect, LockFlags.Read, null };
            int      result = (int)LockMethod.Invoke(null, args);

            wicImageLock = new WICBitmapLock(args[3]);
            return(result == 0);
        }
Exemple #3
0
        public WICBitmapLock Lock(int x, int y, int width, int height)
        {
            Int32Rect lockRect = new Int32Rect(x, y, width, height);

            object[] args   = new object[] { _wicBitmap, lockRect, LockFlags.Read, null };
            int      result = (int)LockMethod.Invoke(null, args);

            if (result != 0)
            {
                throw new Win32Exception(result, "Failed to lock bytes");
            }
            WICBitmapLock wicImageLock = new WICBitmapLock(args[3]);

            return(wicImageLock);
        }