//Get ready to scan the memory for the value
        public void StartScan(bool IsRescan)
        {
            this.IsRescan = IsRescan;
            //Check if the thread is already defined or not.
            if (ScanThreads != null)
                for (int ecx = 0; ecx < ScanThreads.Count; ecx++)
                    //If the thread is already defined and is Alive,
                    if (ScanThreads[ecx].IsAlive)
                    {
                        //raise the event that shows that the last scan task is canceled
                        //(because a new task is going to be started as wanted),
                        ScanCanceledEventArgs cancelEventArgs = new ScanCanceledEventArgs();
                        ScanCanceled(this, cancelEventArgs);

                        //and then abort the alive thread and so cancel last scan task
                        ScanThreads[ecx].Abort();
                    }

            //Make necessary preperations for scan
            PrepareScan();

            //Start multiple threads scanning for our new value
            for (int ecx = 0; ecx < ScanThreadCount; ecx++)
            {
                Thread ScanThread;
                if (!IsRescan)
                    ScanThread = new Thread(MemoryScanner);
                else
                    ScanThread = new Thread(MemoryRescanner);
                ScanThread.Priority = ThreadPriority.AboveNormal;
                ScanThread.Start();
                ScanThreads.Add(ScanThread);
            }
        }
        //Called when scan is aborted
        void scan_ScanCanceled(object sender, ScanCanceledEventArgs e)
        {
            Canceled = true;
            AddressListView.VirtualListSize = 0;
            UpdateFoundTimer.Enabled = false;
            AddressListView.Items.Clear();
            AddressCount.Text = "";
            ProgressBar.Value = 0;
            AbortScanButton.Enabled = false;
            StartScanButton.Enabled = false;
            AddressCount.Text = "Aborted Scan";

            MessageBox.Show("Scan canceled by the user.", "Scan canceled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
        //Cancels this scan
        public void CancelScan()
        {
            //Raise scan canceled event
            ScanCanceledEventArgs cancelEventArgs = new ScanCanceledEventArgs();
            ScanCanceled(this, cancelEventArgs);

            //Abort all threads
            for (int ecx = 0; ecx < ScanThreads.Count; ecx++)
                ScanThreads[ecx].Abort();
        }