Exemple #1
0
 public XORDecryption()
 {
     Pool = new PoolThread();
     InitThreads();
     Pool.TaskIsFinished        = TaskIsFinished;
     Pool.ReportingTaskProgress = ReportTask;
 }
Exemple #2
0
        /// <summary>
        /// Init the combination process
        /// </summary>
        public void Combine()
        {
            int threadFactor = MAX_NUMBER_OF_THREADS;

            if (MAX_NUMBER_OF_THREADS >= this.Combinations)
            {
                threadFactor = this.Combinations - 2;
            }
            if (this.Combinations <= threadFactor)
            {
                IntegerNumber startNumber = new IntegerNumber(this.WordSize);
                CreateDigits(ref startNumber);
                Word[] words = this.Combine(startNumber, new int[] { 0, this.Combinations });
                FillWords(words);
            }
            else
            {
                this.PoolBgTask_Combiner = new PoolThread();
                this.PoolBgTask_Combiner.ReportingTaskProgress += ReportTask;
                this.PoolBgTask_Combiner.TaskIsFinished        += TaskIsFinished;
                this.InitThreads();
                //this.PoolBgTask_Combiner =
                //    new PoolBgTask<int, Word>();
                //CreateBGTask((int)((double)this.Combinations / threadFactor),
                //    (int)((double)this.Permutations / threadFactor));
            }

            while (!this.PoolBgTask_Combiner.TaskReady)
            {
            }
        }
 static void Run()
 {
     for (int i = 0; i < numThreads; i++)
     {
         int threadNum = i;
         workers[i] = new PoolThread(threadNum);
     }
 }
Exemple #4
0
        public void Execute(Action task)
        {
            // Enqueue the task.
            bool anIdleThreadExist = myTaskQueue.Enqueue(task);

            // If there is no free idle thread then start one if it does not exceed number of maximum threads.
            if (!anIdleThreadExist)
            {
                lock (myNumberOfThreadsManipulator)
                {
                    if (myNumberOfThreads < myMaxNumberOfThreads)
                    {
                        ++myNumberOfThreads;

                        PoolThread aThread = new PoolThread(this);
                        aThread.start();
                    }
                }
            }
        }