Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:05:20+00:00 2026-06-15T23:05:20+00:00

This is my code: Action<int, ProgressBar, Label, Label, int, Button> downloadFileAsync = (i, pb,

  • 0

This is my code:

    Action<int, ProgressBar, Label, Label, int, Button> downloadFileAsync = (i, pb, label2, label1, ServID, button1) =>
    {
        var bd = AppDomain.CurrentDomain.BaseDirectory;
        var fn = bd + "/" + i + ".7z";
        var down = new WebClient();
        DownloadProgressChangedEventHandler dpc = (s, e) =>
        {
            label1.Text = "Download Update: " + i + " / " + ServID;
            int rec =Convert.ToInt16(e.BytesReceived / 1024);
            int total =Convert.ToInt16(e.TotalBytesToReceive / 1024)  ;
            label2.Text = "Downloaded: " + rec.ToString() + "KB / " + total.ToString() + " KB";
            pb.Value = e.ProgressPercentage;
        };
        AsyncCompletedEventHandler dfc = null;  dfc = (s, e) =>
        {
            label1.Text = "Extracting Files...";
            Rar Ra = new Rar();
            Ra.Open(i + ".7z");
            Ra.Unrar(AppDomain.CurrentDomain.BaseDirectory);
            File.Delete(fn);
            down.DownloadProgressChanged -= dpc;
            down.DownloadFileCompleted -= dfc;
            down.Dispose();
            if (ServID == i)
            {
                button1.Enabled = true;
                label1.Text = "Have Fun In-Game...";
                label2.Text = "Done...";
            }
        };
        down.DownloadProgressChanged += dpc;
        down.DownloadFileCompleted += dfc;
        down.DownloadFileAsync(new Uri("http://unknowndekaron.net/updatee/" + i + "/" + i + ".7z"), fn);
    };

And This is My Call:

                while (i <= ServID)
                {
                    downloadFileAsync(i, progressBar1, label2, label1, ServID, button1);
                    i++;
                }

Decompress:

    public void Decompress(int i)
    {

        Rar Ra = new Rar();
        Ra.Open(i + ".7z");
        Ra.Unrar(AppDomain.CurrentDomain.BaseDirectory);

    }

In this code program downloads all the updates at once…
It starts to decomprees the first one which’s download is completed completed.
I need the app to download only one update at once and then decompreeses it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:05:21+00:00Added an answer on June 15, 2026 at 11:05 pm

    You can use unelegant solution with using booleans:

    You should move the top level lambda into new async method. You can call it in while normaly. After that declare boolean downloadCompleted on the start of your top level lambda and set it to false. Then go to AsyncCompletedEventHandler and at the end set the value of downloadCompleted to true – this will signalize the last while loop that we have finished. End of top level lamba should wait until fullfillment of downloading and compressing. This won’t change the state of the application to “not responding”.

    Example

    Call:

        downloadFileAsync = (i, pb, label2, label1, ServID, button1) =>
        {
            Download(i, pb, label2, label1, ServID, button1);
        };
    

    New method:

        public async Task<int> Download(...)
        {
            bool downloadCompleted = false;
            var bd = AppDomain.CurrentDomain.BaseDirectory;
            var fn = bd + "/" + i + ".7z";
            var down = new WebClient();
            DownloadProgressChangedEventHandler dpc = (s, e) =>
            {
                label1.Text = "Download Update: " + i + " / " + ServID;
                int rec = Convert.ToInt16(e.BytesReceived / 1024);
                int total = Convert.ToInt16(e.TotalBytesToReceive / 1024);
                label2.Text = "Downloaded: " + rec.ToString() + "KB / " + total.ToString() + " KB";
                pb.Value = e.ProgressPercentage;
            };
            AsyncCompletedEventHandler dfc = null; dfc = (s, e) =>
            {
                label1.Text = "Extracting Files...";
                Rar Ra = new Rar();
                Ra.Open(i + ".7z");
                Ra.Unrar(AppDomain.CurrentDomain.BaseDirectory);
                File.Delete(fn);
                down.DownloadProgressChanged -= dpc;
                down.DownloadFileCompleted -= dfc;
                down.Dispose();
                if (ServID == i)
                {
                    button1.Enabled = true;
                    label1.Text = "Have Fun In-Game...";
                    label2.Text = "Done...";
                }
                downloadCompleted = true;
            };
            down.DownloadProgressChanged += dpc;
            down.DownloadFileCompleted += dfc;
            down.DownloadFileAsync(new Uri("http://unknowndekaron.net/updatee/" + i + "/" + i + ".7z"), fn);
            while (!downloadCompleted)
                ;
        }
    

    Calling while loop can stay as it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this code in my submit form <form id=myform action='hello.php' method='GET'> <input type=button
Hello i have this code var queue = new BlockingCollection<int>(); queue.Add(0); var producers =
I need some help translating this code from c# to vb.net: private static Action<int,
This code works well: UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame]; [pickerView addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
Im planing on using this code to make random sounds play with an action,
I have this html code: <div class=action> some_text <a class=delete_action name=q1>some</a> </div> <div class=action>
i have this code but i can't see the action when i click on
I have wrote this code for c# void SelectionSort() { clearFontColor(); int i, j,
In Effective Java (page 275), there is this code segment: ... for (int i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.