SetProgress() 공개 메소드

public SetProgress ( int percent ) : void
percent int
리턴 void
예제 #1
0
        public static bool DownloadAndInstall(Uri downloadFrom, string fileName, bool exitToInstall)
        {
            WebClient client         = new WebClient();
            string    downloadedFile = Path.Combine(GetDownloadDirectory(), fileName);
            bool      completed      = false;
            bool      success        = false;

            downloadedFile = FindNonexistantFile(downloadedFile);

            DownloadProgressDialog downloadProgressDialog = new DownloadProgressDialog();

            client.DownloadProgressChanged += (sender, e) => { downloadProgressDialog.SetProgress(e.ProgressPercentage); };
            client.DownloadFileCompleted   += (sender, e) => {
                completed = true;
                downloadProgressDialog.DialogResult = DialogResult.OK;
            };

            client.DownloadFileAsync(downloadFrom, downloadedFile);
            var result = downloadProgressDialog.ShowDialog();

            if (result == DialogResult.OK && completed)
            {
                success = Install(downloadedFile, exitToInstall);
            }

            client.Dispose();
            downloadProgressDialog.Dispose();
            return(success);
        }
예제 #2
0
        public static bool DownloadAndInstall(Uri downloadFrom, string fileName, bool exitToInstall)
        {
            WebClient client = new WebClient();
            string downloadedFile = Path.Combine(GetDownloadDirectory(), fileName);
            bool completed = false;
            bool success = false;

            downloadedFile = FindNonexistantFile(downloadedFile);

            DownloadProgressDialog downloadProgressDialog = new DownloadProgressDialog();
            client.DownloadProgressChanged += (sender, e) => { downloadProgressDialog.SetProgress(e.ProgressPercentage); };
            client.DownloadFileCompleted += (sender, e) => {
                completed = true;
                downloadProgressDialog.DialogResult = DialogResult.OK;
            };

            client.DownloadFileAsync(downloadFrom, downloadedFile);
            var result = downloadProgressDialog.ShowDialog();

            if (result == DialogResult.OK && completed) {
                success = Install(downloadedFile, exitToInstall);
            }

            client.Dispose();
            downloadProgressDialog.Dispose();
            return success;
        }