private void btnRefresh_Click(object sender, EventArgs e) { // Do some long-winded task here System.Threading.Thread.Sleep(3000); // Update the UI by redrawing the form and its contents this.Update(); }In this example, the btnRefresh_Click event handler does some long task that takes three seconds to complete. Meanwhile, the Update method updates the form by redrawing it, ensuring that the UI remains responsive to the user. This method is part of the System.Windows.Forms namespace, which is included in the .NET Framework Class Library.