c#事件委托需要返回int,1表示成功,0表示失败

weatch 2012-03-14 04:33:13
public delegate void DialOutEventHandler(object sender, AxLib._OnDialOutEvent e)
public AxLib._OnDialOutEvent(int i)
应该怎么实现呢,
AxLib._OnDialOutEvent e=new AxLib._OnDialOutEvent(object sender, AxLib._OnDialOutEvent e);
int ai=e.i;
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weatch 2012-03-14
  • 打赏
  • 举报
回复
public AxLib.LinkSocket axLink;
public Main()
{
InitializeComponent();
axLink = new AxLib.LinkSocket();

axLink.OnDialOut += new AxLib.DialOutEventHandler(ConDiaOut_Tel);

}

public delegate void DialOutEventHandler(object sender, AxLib._OnDialOutEvent e);

public int aireturn = 0;


private void ConDiaOut_Tel(object sender, AxLib._OnDialOutEvent e)
{
AxLib._OnDialOutEvent outtel = new AxLib._OnDialOutEvent(e.iReturn);
if (outtel.iRe == 0)
{
//axLink.OnDialOut(0);
axLink.DialOut(textBox1.Text);
conn.Log.SetLog("成功:" + textBox1.Text + "_" + e.iRe.ToString());
}
else
{
conn.Log.SetLog("失败" + textBox1.Text +"_"+ e.iRe.ToString());
}

}

protected void OnMyEvent(AxLib._OnDialOutEvent e)
{
if (elvc1 != null)
{
elvc1(this, e);
aiRe = 0;
conn.Log.SetLog("代码" + e.iRe.ToString() + "");
}
}
public void RaiseEvent()
{
// 步骤7,触发事件

AxLib._OnDialOutEvent e = new AxLib._OnDialOutEvent(0);
OnMyEvent(e);
}



private void button3_Click(object sender, EventArgs e)
{
try
{
RaiseEvent();


}
catch (Exception ex)
{
conn.Log.SetLog("错误事件" + ex.Message + ex.Source + ex.StackTrace +
}
}
threenewbee 2012-03-14
  • 打赏
  • 举报
回复
不知道你什么意思。

委托你懂么?

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧