c# event事件编译后变成了什么?
2015-05-27 14:59
260 查看
源码:
public delegate void wt();
public void f1()
{
MessageBox.Show("a");
}
public event wt sj;
public Form1()
{
InitializeComponent();
sj+=new wt(f1);
sj();
}
或写成
sj+=new wt(f1);
sj.Invoke();
编译后:
public delegate void wt();
public void f1()
{
MessageBox.Show("a");
}
private wt sj;
public event wt sj
{
add
{
wt wt2;
wt sj = this.sj;
do
{
wt2 = sj;
wt wt3 = (wt) Delegate.Combine(wt2, value);
sj = Interlocked.CompareExchange<wt>(ref this.sj, wt3, wt2);
}
while (sj != wt2);
}
remove
{
wt wt2;
wt sj = this.sj;
do
{
wt2 = sj;
wt wt3 = (wt) Delegate.Remove(wt2, value);
sj = Interlocked.CompareExchange<wt>(ref this.sj, wt3, wt2);
}
while (sj != wt2);
}
}
public Form1()
{
this.InitializeComponent();
this.sj += new wt(this.f1);
this.sj();
}
public delegate void wt();
public void f1()
{
MessageBox.Show("a");
}
public event wt sj;
public Form1()
{
InitializeComponent();
sj+=new wt(f1);
sj();
}
或写成
sj+=new wt(f1);
sj.Invoke();
编译后:
public delegate void wt();
public void f1()
{
MessageBox.Show("a");
}
private wt sj;
public event wt sj
{
add
{
wt wt2;
wt sj = this.sj;
do
{
wt2 = sj;
wt wt3 = (wt) Delegate.Combine(wt2, value);
sj = Interlocked.CompareExchange<wt>(ref this.sj, wt3, wt2);
}
while (sj != wt2);
}
remove
{
wt wt2;
wt sj = this.sj;
do
{
wt2 = sj;
wt wt3 = (wt) Delegate.Remove(wt2, value);
sj = Interlocked.CompareExchange<wt>(ref this.sj, wt3, wt2);
}
while (sj != wt2);
}
}
public Form1()
{
this.InitializeComponent();
this.sj += new wt(this.f1);
this.sj();
}
相关文章推荐
- 请问有没有人知道可不可以根据已经编译好的exe(这里具体指窗体),通过什么工具可以看到它里面的某一个控件的事件里面的代码(比如timer的tick)。
- babel 编译后 this 变成了 undefined
- Windows程序中什么事件发生时,窗口过程会收到一条WM_SIZE消息
- c#中的委托是什么,事件是不是一种委托
- C# Event事件 详细讲解
- .NET编译时都做了一些什么
- 精品赏析:一个.NET程序在编译和运行时都做了些什么?
- onmouseover事件中把鼠标变成小手形状
- ObjectList的自动分页要处理一个什么事件才使下一页,上一页有效?
- linux编译安装软件 ./configure命令enable和with有什么区别
- 什么是交叉编译
- Android Studio 中的类文件前标识图标显示为 j 而不是C,代码的左边没有了颜色显示,布局文件的引用也没有蓝色显示,代码大部分变成了白色。项目能正常编译运行,且敲代码时也没有了提示的问题
- Android 当修改一些代码时,使用什么编译命令可以最有效率
- 疯狂的预编译加类型推导能孵化什么吗?
- DotNet项目编译事件的定义
- 在javascript或者jQuery中绑定按钮点击事件,和在HTML 标签中直接调用onclick属性有什么区别?
- 给事件处理函数添加 return false的作用是什么?
- 什么是事件冒泡?如何用jquery/js阻止事件冒泡?阻止冒泡有什么作用?小生来抛个砖。
- 事件、IE与火狐的事件机制有什么区别? 如何阻止冒泡?
- 在JSP编译的时候,服务器内部做了什么?