Ejemplo n.º 1
0
        /// <summary>
        /// Parallel decompress
        /// </summary>
        protected void DecompressParallel()
        {
            //Create thread pool
            var tPool = new ThreadsManager(base._totalThreads);

            try
            {
                Thread readThread = new Thread(this.ReadFromFile);
                readThread.Start();
                Thread writeThread = new Thread(this.WriteToFile);
                writeThread.Start();

                for (int i = 0; i < base._totalThreads; i++)
                {
                    tPool.AddThread(DataProcessing);
                }
                tPool.StartThreads();

                tPool.WaitAll();

                IsWorkComplete = true;

                writeThread.Join();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tPool.Dispose();
            }
        }
Ejemplo n.º 2
0
        //Check if the shuttingDownCan be done safely
        public void ShuttingDownProcess()
        {
            //Check for fullscreen state
            if (IsFullScreen)
            {
                IsFullScreen = false;
                return;
            }

            if (OnShuttingDown != null)
            {
                OnShuttingDown(this, null);
            }

            //Independant Threaded work are still running, waiting them for shutting down.
            if (RunningThreadedWork.Count > 0)
            {
                return;
            }

            ThreadsManager.IsShuttingDown = true;

            if (ThreadsManager.RunningThreads > 0)
            {
                return;
            }

            ThreadsManager.Dispose();

            IsShuttingDownSafe = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parallel compressing
        /// </summary>
        protected void CompressParallel()
        {
            //Create pool of threads
            var tPool = new ThreadsManager(base._totalThreads);

            try
            {
                //Thread for reading
                Thread readThread = new Thread(this.ReadFromFile);
                readThread.Start();
                //Thread for writing
                Thread writeThread = new Thread(this.WriteToFile);
                writeThread.Start();

                //Add threads
                for (int i = 0; i < base._totalThreads; i++)
                {
                    tPool.AddThread(DataProcessing);
                }

                //Start threads
                tPool.StartThreads();

                //Waiting
                tPool.WaitAll();

                IsWorkComplete = true;

                //Wait finish write
                writeThread.Join();
            }
            finally
            {
                tPool.Dispose();
            }
        }