Exemplo n.º 1
0
        public static byte[] EncodeParallelExample(Gif gif)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var encodeProgress = new EncodeProgress();

            gif.EncodeParallel(progress =>
            {
                Console.WriteLine("Encode progress: {0}/{1}", progress.Progress, progress.FrameCount);
                encodeProgress = progress;
            });

            while (!encodeProgress.Completed)
            {
                Thread.Sleep(100);
            }

            if (encodeProgress.Exception != null)
            {
                throw encodeProgress.Exception;
            }

            stopwatch.Stop();

            Console.WriteLine("GIF encoded in {0:n2}s to binary.", stopwatch.Elapsed.TotalSeconds);

            return(encodeProgress.Bytes);
        }