単純なアップデータ プログラムに問題があります。アーカイブをダウンロードして解凍する必要があります。まあ、これはうまくいきます。しかし、プログレスバーを克服できません。setProgressBar(progressBar1.Maximum/20) でうまく表示されます。しかし、その値の他のすべての変更はまったく表示されません。この動作の理由を定義できません。誰でも私を助けることができますか?
UPD: e.ProgressPercentage は常に 0 を返し、ダウンロードが完了する直前に 100 を 1 回だけ返すようです。
これが私のコードです:
static EventWaitHandle _waitHandle = new AutoResetEvent(false);
void UpdaterForm_Shown(object sender, System.EventArgs e)
{
    setProgressBar(progressBar1.Maximum/20);
    UpdateProgram(address, login, password);
    setProgressBar(progressBar1.Maximum);
    ExecuteProgram(Path + "../" + programName + ".exe");
    Application.Exit();     
}
private void UpdateProgram(string pathToUpdateArchive, string login, string pass)
{
    string downloadedArchive = null;
    Thread downloadAsync = new Thread(() => DownloadFileFromFtp(pathToUpdateArchive, login, pass, out downloadedArchive));
    downloadAsync.Name = "downloadAsync";
    downloadAsync.Start();
    _waitHandle.WaitOne();
    ExtractFile(downloadedArchive, Path + "/../");
}
private void DownloadFileFromFtp(string address, string login, string password, out string archivePath)
{
    fileName = address.Substring(address.LastIndexOf('/') + 1);
    try
    {
        WebClient wc = new WebClient();
        wc.Credentials = new NetworkCredential(login, password);
        wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
        wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);     
        archivePath =Path + fileName;
        wc.DownloadFileAsync(new Uri(address), archivePath);
    }
    catch
    {
    }
}
void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
    setProgressBar(e.ProgressPercentage*7/10 + 10);
}
void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
    _waitHandle.Set();
}
private void setProgressBar(int value)
{
    if (progressBar1.InvokeRequired)
        this.BeginInvoke((MethodInvoker)delegate { progressBar1.Value = value; });
    else
        progressBar1.Value = value;
}