using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace Teseweituo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void print(string s)
{
MessageBox.Show(s);
}
public delegate void myprint(string s);
public event myprint myevent;
private void button4_Click(object sender, EventArgs e)
{
Thread t1;
t1 = new Thread(new ThreadStart(BackgroundProcess));
t1.Start();
}
private void BackgroundProcess()
{
myprint mp = new myprint(print);
print("委托调用");
myevent += new myprint(print);
myevent("事件触发调用");
this.BeginInvoke(myevent, "异步事件调用");
this.BeginInvoke(new myprint(print), "异步委托调用");
myevent -= new myprint(print);
}
}
}