“WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi” Kode Jawaban

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi

private void button1_Click(object sender, EventArgs e)
{
    // To keep the user from repeatedly pressing the button, let's disable it
    button1.Enabled = false;

    // Capture the current text ("ABC" in your example)
    string originalText = label1.Text;

    // Create a background worker to sleep for 2 seconds...
    var backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(2));

    // ...and then set the text back to the original when the sleep is done
    // (also, re-enable the button)
    backgroundWorker.RunWorkerCompleted += (s, ea) =>
    {
        label1.Text = originalText;
        button1.Enabled = true;
    };

    // Set the new text ("CDE" in your example)
    label1.Text = "CDE";

    // Start the background worker
    backgroundWorker.RunWorkerAsync();
}
Khaldoun Kalash

Jawaban yang mirip dengan “WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi”

Pertanyaan yang mirip dengan “WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi”

Lebih banyak jawaban terkait untuk “WPF Ubah konten tombol tunggu 5 secound dan kemudian ubah lagi” di C#

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya