Beispiel #1
0
        /// <summary>
        /// Constructs the adapter, giving the multi-threaded collider it belongs to and the collider object to execute in the managed thread.
        /// </summary>
        /// <param name="multiThreadedCollider">The multi-threaded collider to which this adapter belongs</param>
        /// <param name="wrappedCollider">The collider which is executed in the managed thread</param>
        public ColliderWorkerAdapter(MultiThreadedMD5Collider <T> multiThreadedCollider, IMD5ColliderAlgorithm wrappedCollider)
        {
            this.multiThreadedCollider = multiThreadedCollider;
            this.wrappedCollider       = wrappedCollider;

            worker                     = new BackgroundWorker();
            worker.DoWork             += DoWork;
            worker.RunWorkerCompleted += RunWorkerCompleted;
        }
Beispiel #2
0
        /// <summary>
        /// Called by a <c>ColliderWorkerAdapter</c> when wrapped collider has finished
        /// </summary>
        /// <param name="successfulCollider"></param>
        internal void SignalWorkIsFinished(IMD5ColliderAlgorithm successfulCollider)
        {
            lock (finishedLock)
            {
                if (this.successfulCollider == null)
                {
                    this.successfulCollider = successfulCollider;
                    updateProgress();
                    Stop();

                    finishedEvent.Set();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Starts the collision search
        /// </summary>
        public void FindCollision()
        {
            progressUpdateTimer.Start();

            finishedEvent.Reset();
            successfulCollider = null;

            foreach (ColliderWorkerAdapter <T> worker in workers)
            {
                worker.StartWork();
            }

            finishedEvent.WaitOne();

            OnPropertyChanged("FirstCollidingData");
            OnPropertyChanged("SecondCollidingData");
        }