36 lines
706 B
C#
36 lines
706 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Event
|
|
{
|
|
class MyClass
|
|
{
|
|
public MyClass()
|
|
{
|
|
DoSomething();
|
|
}
|
|
|
|
public event MyEventHandler MyEvent;
|
|
|
|
public delegate void MyEventHandler(object sender, EventArgs e);
|
|
|
|
public void DoSomething()
|
|
{
|
|
if (MyEvent != null)
|
|
{
|
|
MessageBox.Show("Tue was du machen sollst.");
|
|
MyEvent(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
|
|
public void SimulatedoSomething()
|
|
{
|
|
DoSomething();
|
|
}
|
|
}
|
|
}
|