using System.Threading.Tasks;
namespace WindowsFormsApp3
public partial class Form1 : Form
private void button1_Click(object sender, EventArgs e)
var c = new Calculator();
c.NewResultFound += OnNewResultFound;
c.NewResultFound += OnNewResult;
c.StartCalculationAsync();
void OnNewResultFound(Calculator sender, CalculatorEventArgs e)
label1.Text = e.Result.ToString();
void OnNewResult(Calculator sender, CalculatorEventArgs e)
delegate void CalculatorEventHandler(Calculator sender, CalculatorEventArgs e);
class CalculatorEventArgs : EventArgs
public int Result { get; set; }
public event CalculatorEventHandler NewResultFound;
public async Task StartCalculationAsync()
int result = r.Next(0, 1000);
var e = new CalculatorEventArgs() { Result = result };
NewResultFound?.Invoke(this, e);