Ejemplo n.º 1
0
        public ImageServerProxy ObtainProxy(Profile profile)
        {
            profile.Push("ObtainProxy");
            int which = WaitHandle.WaitAny(proxyGates);
            ImageServerProxy result = proxies[which];

            profile.Pop();
            return(result);
        }
Ejemplo n.º 2
0
        public ImageServerPool()
        {
            int count = !Program.ProfileMode ? Environment.ProcessorCount : 1;

            proxies    = new ImageServerProxy[count];
            proxyGates = new EventWaitHandle[count];
            for (int i = 0; i < count; i++)
            {
                proxies[i]    = new ImageServerProxy();
                proxyGates[i] = new EventWaitHandle(true /*initially available*/, EventResetMode.AutoReset);
            }
        }
Ejemplo n.º 3
0
        public static ManagedBitmap ShrinkExpandWPF(Profile profile, ManagedBitmap source, double factor)
        {
            profile.Push("ImageClient.ShrinkExpandWPF");
            ImageServerProxy server = serverPool.ObtainProxy(profile);

            try
            {
                ManagedBitmap result = server.ShrinkExpandWPF(source, factor, profile);
                return(result);
            }
            finally
            {
                serverPool.ReleaseProxy(server);
                profile.Pop();
            }
        }
Ejemplo n.º 4
0
        public static ManagedBitmap CreateTileGDI(Profile profile, ManagedBitmap source, int offsetX, int offsetY, int drawWidth, int drawHeight, int targetWidth, int targetHeight)
        {
            profile.Push("ImageClient.CreateTileGDI");
            ImageServerProxy server = serverPool.ObtainProxy(profile);

            try
            {
                ManagedBitmap result = server.CreateTile(source, offsetX, offsetY, drawWidth, drawHeight, targetWidth, targetHeight, profile);
                return(result);
            }
            finally
            {
                serverPool.ReleaseProxy(server);
                profile.Pop();
            }
        }
Ejemplo n.º 5
0
        public static ManagedBitmap ResizeGDI(Profile profile, ManagedBitmap source, int targetWidth, int targetHeight)
        {
            profile.Push("ImageClient.ResizeGDI");
            ImageServerProxy server = serverPool.ObtainProxy(profile);

            try
            {
                ManagedBitmap result = server.ResizeGDI(source, targetWidth, targetHeight, profile);
                return(result);
            }
            finally
            {
                serverPool.ReleaseProxy(server);
                profile.Pop();
            }
        }
Ejemplo n.º 6
0
        public static ManagedBitmap LoadAndOrientGDI(Profile profile, string path, int rightRotations, out RotateFlipType exifOrientation)
        {
            profile.Push("ImageClient.LoadAndOrientGDI");
            ImageServerProxy server = serverPool.ObtainProxy(profile);

            try
            {
                ManagedBitmap result = server.LoadAndOrientGDI(path, rightRotations, profile, out exifOrientation);
                return(result);
            }
            finally
            {
                serverPool.ReleaseProxy(server);
                profile.Pop();
            }
        }
Ejemplo n.º 7
0
        public void Dispose()
        {
            Task <bool>[] disposes = new Task <bool> [proxies.Length];
            for (int i = 0; i < proxies.Length; i++)
            {
                ImageServerProxy proxy = proxies[i];
                proxies[i] = null;
                EventWaitHandle proxyGate = proxyGates[i];
                proxyGates[i] = null;

                disposes[i] = new Task <bool>(
                    delegate()
                {
                    proxy.Dispose();
                    proxyGate.Dispose();
                    return(false);
                });
                disposes[i].Start();
            }
            Task.WaitAll(disposes);
        }
Ejemplo n.º 8
0
        public void ReleaseProxy(ImageServerProxy proxy)
        {
            int which = Array.IndexOf(proxies, proxy);

            proxyGates[which].Set();
        }