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

  • Home
  • SEARCH
  • 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 77321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:48:43+00:00 2026-05-10T20:48:43+00:00

I have in my Form constructor, after the InitializeComponent the following code: using (WebClient

  • 0

I have in my Form constructor, after the InitializeComponent the following code:

using (WebClient client = new WebClient()) {     client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);     client.DownloadDataAsync('http://example.com/version.txt'); } 

When I start my form, the UI doesn’t appears till client_DownloadDataCompleted is raised. The client_DownloadDataCompleted method is empty, so there’s no problem there.

What I’m doing wrong? How is supposed to do this without freezing the UI?

Thanks for your time.
Best regards.

FULL CODE:

Program.cs

using System; using System.Windows.Forms;  namespace Lala {     static class Program     {         /// <summary>         /// The main entry point for the application.         /// </summary>         [STAThread]         static void Main()         {             Application.EnableVisualStyles();             Application.SetCompatibleTextRenderingDefault(false);             Application.Run(new Form1());         }     } } 

Form1.cs

using System; using System.Net; using System.Windows.Forms;  namespace Lala {     public partial class Form1 : Form     {         WebClient client = new WebClient();          public Form1()         {             client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);             client.DownloadDataAsync(new Uri('http://www.google.com'));             InitializeComponent();         }          void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)         {             textBox1.Text += 'A';         }     }      partial class Form1     {         /// <summary>         /// Required designer variable.         /// </summary>         private System.ComponentModel.IContainer components = null;          /// <summary>         /// Clean up any resources being used.         /// </summary>         /// <param name='disposing'>true if managed resources should be disposed; otherwise, false.</param>         protected override void Dispose(bool disposing)         {             if (disposing && (components != null))             {                 components.Dispose();             }             base.Dispose(disposing);         }          #region Windows Form Designer generated code          /// <summary>         /// Required method for Designer support - do not modify         /// the contents of this method with the code editor.         /// </summary>         private void InitializeComponent()         {             this.button1 = new System.Windows.Forms.Button();             this.textBox1 = new System.Windows.Forms.TextBox();             this.SuspendLayout();             //              // button1             //              this.button1.Location = new System.Drawing.Point(12, 12);             this.button1.Name = 'button1';             this.button1.Size = new System.Drawing.Size(75, 23);             this.button1.TabIndex = 0;             this.button1.Text = 'button1';             this.button1.UseVisualStyleBackColor = true;             //              // textBox1             //              this.textBox1.Location = new System.Drawing.Point(12, 41);             this.textBox1.Multiline = true;             this.textBox1.Name = 'textBox1';             this.textBox1.Size = new System.Drawing.Size(468, 213);             this.textBox1.TabIndex = 1;             //              // Form1             //              this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;             this.ClientSize = new System.Drawing.Size(492, 266);             this.Controls.Add(this.textBox1);             this.Controls.Add(this.button1);             this.Name = 'Form1';             this.Text = 'Form1';             this.ResumeLayout(false);             this.PerformLayout();          }          #endregion          private System.Windows.Forms.Button button1;         private System.Windows.Forms.TextBox textBox1;     } } 
  • 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. 2026-05-10T20:48:44+00:00Added an answer on May 10, 2026 at 8:48 pm

    Now that we’ve got full code, I can say I’m definitely not seeing the problem – not quite as described, anyway.

    I’ve got a bit of logging to indicate just before and after the DownloadDataAsync calls, and when the completed handler is fired. If I download a large file over 3G, there is a pause between ‘before’ and ‘after’ but the UI comes up ages before the file completes downloading.

    I have a suspicion that the connect is done synchronously, but the actual download is asynchronous. That’s still unfortunate, of course – and possibly punting all of that into a different thread is the way to go – but if I’m right it’s at least worth knowing about.

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

Sidebar

Ask A Question

Stats

  • Questions 226k
  • Answers 226k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try the following: var hasAll = !search.Except(CityList).Any(); By the way,… May 13, 2026 at 1:16 am
  • Editorial Team
    Editorial Team added an answer A simple and fast approach, assuming that you have the… May 13, 2026 at 1:16 am
  • Editorial Team
    Editorial Team added an answer You will need a better editor than Notepad. With Notepad,… May 13, 2026 at 1:16 am

Related Questions

I have a Windows user control that reads events from the application log of
One-line summary: What is the best practice for unhooking event handlers created in the
Brief question What command can I use to make my DataSet refresh it's connection
I have a windows form application in which the Form1 object's initial WindowState ==

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.