两个程序间通讯 用Event抛出就行, 在你的B程序Distroy的时候, 抛出相关事件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to LeoMaya(我是L.W, 这是我的故事)能否说的具体一点 public class InstanceA{private InstanceB B;public InstanceA(){B = new InstanceB();B.OnBDestroy += new BDestroyEventHandler(InstanceA_OnBDestroy);}private void InstanceA_OnBDestroy(object sender, BDestroyEventArgs e){MessageBox.Show(e.YourReturnValue.ToString());}}public delegate void BDestroyEventHandler(object sender, BDestroyEventArgs e);public class InstanceB{public event BDestroyEventHandler OnBDestroy;//B's Destroy Functionpublic void Close(){if(OnBDestroy != null){BDestroyEventArgs e = new BDestroyEventArgs("testing result");OnBDestroy(this, e);}}}public class BDestroyEventArgs : EventArgs{private object _yourReturnValue;public BDestroyEventArgs(object ret){_yourReturnValue = ret;}public object YourReturnValue{get{return _yourReturnValue;}}} 可能我没有说清楚,这里的A是一个应用程序(A.exe),B也是一个应用程序(B.exe),而不是new处理的实例 最快的方法是,使用Remoting,当B退出时,首先向A发送一个消息。 如果A,B是应用程序,A中的下列代码有效吗private InstanceB B;B = new InstanceB();B.OnBDestroy += new BDestroyEventHandler(InstanceA_OnBDestroy);A不能引用B.exe event可以由你自己定义, 什么时候抛出, 抛出些什么东西, 由谁抛出并不是固定的, 反正都是在B的Destroy事件里面抛出的 GDI+ 所画的线移动时,闪烁问题,高手来 请问这种需求能否实现? js中分割字符串,并循环遍历 判断控件的Text值只能是数字 匿名方法受到的限制是不是也存在于在事件处理程序中? 如何实现在页面加载时改写div的innerHTML 如何通过C#将excel的数据转换为xml? 请问如何在ComboBox控件中添加CheckBox项??? 如何实现哈希表的多线程同步读写。 请问一下那里有关于c#语音聊天和视频传输方面的资料阿 GRID如何动态添加列?请各位多多指教,谢谢了 DataGrid中del按钮列中,调用deletecommand事件之前可否加询问窗体?
能否说的具体一点
{
private InstanceB B;public InstanceA()
{
B = new InstanceB();
B.OnBDestroy += new BDestroyEventHandler(InstanceA_OnBDestroy);
}private void InstanceA_OnBDestroy(object sender, BDestroyEventArgs e)
{
MessageBox.Show(e.YourReturnValue.ToString());
}
}public delegate void BDestroyEventHandler(object sender, BDestroyEventArgs e);
public class InstanceB
{
public event BDestroyEventHandler OnBDestroy;//B's Destroy Function
public void Close()
{
if(OnBDestroy != null)
{
BDestroyEventArgs e = new BDestroyEventArgs("testing result");
OnBDestroy(this, e);
}
}
}public class BDestroyEventArgs : EventArgs
{
private object _yourReturnValue;public BDestroyEventArgs(object ret)
{
_yourReturnValue = ret;
}public object YourReturnValue
{
get{return _yourReturnValue;}
}
}
A中的下列代码有效吗private InstanceB B;
B = new InstanceB();
B.OnBDestroy += new BDestroyEventHandler(InstanceA_OnBDestroy);A不能引用B.exe