예제 #1
0
        /// <summary>
        /// Asynchronous way to get modified file list
        /// </summary>
        /// <param name="localPath">local archive path</param>
        /// <param name="progressCallback">Progress callback</param>
        /// <param name="completedCallback">Completed callback</param>
        /// <returns>true if successfully submits</returns>
        public bool getModifiedFilesAsync(string localPath, EventHandler <ProgressEventArgs> progressCallback, EventHandler <CompletedEventArgs> completedCallback)
        {
            if (string.IsNullOrEmpty(localPath) || null == progressCallback || null == completedCallback)
            {
                return(false);
            }

            BackgroundWorker bw = new BackgroundWorker();

            bw.WorkerReportsProgress      = true;
            bw.WorkerSupportsCancellation = true;
            bw.DoWork             += new DoWorkEventHandler(bw_DoWork);
            bw.ProgressChanged    += new ProgressChangedEventHandler(bw_ProgressChanged);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
            bgWorkerInfo           = new WorkerInformation()
            {
                LocalPath        = localPath,
                Worker           = bw,
                CompletedHandler = completedCallback,
                ProgressHandler  = progressCallback
            };

            if (!bw.IsBusy)
            {
                bw.RunWorkerAsync();
                Console.ReadLine();

                return(true);
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Asynchronous way to get modified file list
        /// </summary>
        /// <param name="localPath">local archive path</param>
        /// <param name="progressCallback">Progress callback</param>
        /// <param name="completedCallback">Completed callback</param>
        /// <returns>true if successfully submits</returns>
        public bool getModifiedFilesAsync(string localPath, EventHandler<ProgressEventArgs> progressCallback, EventHandler<CompletedEventArgs> completedCallback)
        {
            if (string.IsNullOrEmpty(localPath) || null == progressCallback || null == completedCallback)
                return false;

            BackgroundWorker bw = new BackgroundWorker();
            bw.WorkerReportsProgress = true;
            bw.WorkerSupportsCancellation = true;
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);
            bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
            bgWorkerInfo = new WorkerInformation()
            {
                LocalPath = localPath,
                Worker = bw,
                CompletedHandler = completedCallback,
                ProgressHandler = progressCallback
            };

            if (!bw.IsBusy)
            {
                bw.RunWorkerAsync();
                Console.ReadLine();

                return true;
            }
            return false;
        }