41 lines
923 B
C#
41 lines
923 B
C#
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;
|
|
|
|
namespace Test_Events
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
int value = 0;
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void buttonStart_Click(object sender, EventArgs e)
|
|
{
|
|
MyClass tc = new MyClass();
|
|
// Hier wird das Event abonniert.
|
|
// Das kann jede Klasse auf die gleiche Weise machen.
|
|
tc.MyEvent += new MyClass.EventDelegate(EventHandler);
|
|
|
|
value = tc.Add(20, 33);
|
|
}
|
|
|
|
void EventHandler(int value)
|
|
{
|
|
//Die ProgressBar updaten
|
|
progressBar.Value = value;
|
|
progressBar.Refresh();
|
|
}
|
|
|
|
}
|
|
}
|