private bool CreateDeploymentReadHelper(
            BackgroundWorker backgroundWorker,
            DoWorkEventArgs doWorkEventArgs,
            Microsoft.SPOT.Debugger.Engine engine,
            ref uint address,
            uint addressStart,
            uint addressEnd,
            uint bytes,
            out byte[] data
            )
        {
            data = new byte[bytes];
            uint iByte = 0;

            while (bytes > 0)
            {
                uint cBytes = System.Math.Min(1024, bytes);
                byte[] buf;

                if (!engine.ReadMemory(address, cBytes, out buf))
                    throw new ApplicationException("Cannot read data");

                buf.CopyTo(data, iByte);

                address += cBytes;
                iByte += cBytes;
                bytes -= cBytes;

                if (backgroundWorker.CancellationPending)
                {
                    doWorkEventArgs.Cancel = true;
                    return false;
                }
            }

            return true;
        }
        private bool CreateDeploymentReadHelper(
                BackgroundWorker backgroundWorker,
                DoWorkEventArgs doWorkEventArgs,
                Microsoft.SPOT.Debugger.Engine engine,
                uint address,                
                byte[] buf
        )
        {
            uint bytesTotal = (uint)buf.Length;
            uint bytesRemaining = bytesTotal;
            uint bytesRead = 0;

            while (bytesRemaining > 0)
            {
                uint cBytes = System.Math.Min(1024, bytesRemaining);
                byte[] bufT;

                if (!engine.ReadMemory(address, cBytes, out bufT))
                    throw new ApplicationException("Cannot read data");

                bufT.CopyTo(buf, bytesRead);

                address += cBytes;
                bytesRead += cBytes;
                bytesRemaining -= cBytes;

                if (backgroundWorker.WorkerReportsProgress)
                {
                    int progress = (int)(100.0 * (double)bytesRead / (double)bytesTotal);
                    backgroundWorker.ReportProgress(progress);
                }

                if (backgroundWorker.CancellationPending)
                {
                    doWorkEventArgs.Cancel = true;
                    return false;
                }
            }

            return true;
        }