using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
public partial class Form1 : Form
async Task<int> CalcAsync()
return await Task.Run(() => Calc());
public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
var context = SynchronizationContext.Current;
context.Send(x => label1.Text = i.ToString(), null);
private async void button2_Click(object sender, EventArgs e)
int result = await CalcAsync();
label2.Text = result.ToString();