Form1 C# with Example



Form1 C# with Example

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace MainForm
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private async void btnCallMethod_Click(object sender, EventArgs e)
        {
            this.Text = await DoWork();
        }

        // See below for code walkthrough...
        private Task DoWork()
        {
            return Task.Run(delegate()
            {
                Thread.Sleep(10000);
                return "Done with work!";
            });
        }
    }
}
 

0 Comment's

Comment Form

Submit Comment