private void asyncCheckoutBtn_Click(object sender, EventArgs e)
        {
            textBoxResult.Clear();

            if (this.m_status == CheckoutManagerState.idle)
            {
                string files = GetFiles();

                // Create configuration
                Item configuration = m_inn.newItem();
                configuration.loadAML(files);

                // Create Aras.IOME.CheckoutManager
                m_cmgr = new CheckoutManager(configuration);

                // Lock all items in the configuration (!File, !Vault, !Located)
                Item lockResult = m_cmgr.Lock();

                if (lockResult.isError())
                {
                    MessageBox.Show(lockResult.getErrorString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                int    numberOfThreads = (int)thCount.Value;
                string targetFolder    = textBoxDestination.Text;

                // Event handlers are attached to Aras.IOME.CheckoutManager events.
                m_cmgr.DownloadFileCompleted        += new Aras.IOME.DownloadFileCompletedEventHandler(HandleDownloadFileCompleted);
                m_cmgr.DownloadFilesCompleted       += new Aras.IOME.DownloadFilesCompletedEventHandler(HandleDownloadFilesCompleted);
                m_cmgr.DownloadFilesProgressChanged += new Aras.IOME.DownloadFilesProgressChangedEventHandler(HandleDownloadFileProgressChanged);

                this.m_failed_count = 0;
                progressBar.Value   = 0;

                // Begin download files asynchronously
                m_cmgr.DownloadFilesAsync(targetFolder, numberOfThreads);

                // Toggle button state
                cancelBtn.Enabled     = true;
                asyncCheckoutBtn.Text = "Pause";
                this.m_status         = CheckoutManagerState.running;
            }
            else if (this.m_status == CheckoutManagerState.running)
            {
                m_cmgr.DownloadFilesPauseAsync();
                cancelBtn.Enabled     = false;
                asyncCheckoutBtn.Text = "Resume";
                this.m_status         = CheckoutManagerState.paused;
            }
            else if (this.m_status == CheckoutManagerState.paused)
            {
                m_cmgr.DownloadFilesResumeAsync();
                cancelBtn.Enabled     = true;
                asyncCheckoutBtn.Text = "Pause";
                this.m_status         = CheckoutManagerState.running;
            }
        }
        private void asyncCheckoutBtn_Click(object sender, EventArgs e)
        {
            textBoxResult.Clear();

            if (this.m_status == CheckoutManagerState.idle)
            {
                string files = GetFiles();

                // Create configuration
                Item configuration = m_inn.newItem();
                configuration.loadAML(files);

                // Create Aras.IOME.CheckoutManager
                m_cmgr = new CheckoutManager(configuration);

                // Lock all items in the configuration (!File, !Vault, !Located)
                Item lockResult = m_cmgr.Lock();

                if (lockResult.isError())
                {
                    MessageBox.Show(lockResult.getErrorString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                int numberOfThreads = (int)thCount.Value;
                string targetFolder = textBoxDestination.Text;

                // Event handlers are attached to Aras.IOME.CheckoutManager events.
                m_cmgr.DownloadFileCompleted += new Aras.IOME.DownloadFileCompletedEventHandler(HandleDownloadFileCompleted);
                m_cmgr.DownloadFilesCompleted += new Aras.IOME.DownloadFilesCompletedEventHandler(HandleDownloadFilesCompleted);
                m_cmgr.DownloadFilesProgressChanged += new Aras.IOME.DownloadFilesProgressChangedEventHandler(HandleDownloadFileProgressChanged);

                this.m_failed_count = 0;
                progressBar.Value = 0;

                // Begin download files asynchronously
                m_cmgr.DownloadFilesAsync(targetFolder, numberOfThreads);

                // Toggle button state
                cancelBtn.Enabled = true;
                asyncCheckoutBtn.Text = "Pause";
                this.m_status = CheckoutManagerState.running;
            }
            else if (this.m_status == CheckoutManagerState.running)
            {
                m_cmgr.DownloadFilesPauseAsync();
                cancelBtn.Enabled = false;
                asyncCheckoutBtn.Text = "Resume";
                this.m_status = CheckoutManagerState.paused;
            }
            else if (this.m_status == CheckoutManagerState.paused)
            {
                m_cmgr.DownloadFilesResumeAsync();
                cancelBtn.Enabled = true;
                asyncCheckoutBtn.Text = "Pause";
                this.m_status = CheckoutManagerState.running;
            }
        }