日期:2014-05-18 浏览次数:21485 次
public delegate void UpdateFaxEventHander(string tifPath); public event UpdateFaxEventHander UpdateFax;
public FrmFaxTaskEdit()
{
InitializeComponent();
Fax.Instance.UpdateFax += new Fax.UpdateFaxEventHander(Instance_UpdateFax);
}
Delegate[] allDlg = new Delegate[this.UpdateFax.GetInvocationList().GetLength(0)];
this.UpdateFax.GetInvocationList().CopyTo(allDlg, 0);
foreach (Delegate dlg in allDlg)
{
if (dlg.Method.Name == "Form1_UpdateFax")
{
//不在绑定
}
else
{
//绑定
UpdateFax += new UpdateFaxEventHander(Form1_UpdateFax);
MessageBox.Show("绑定成功");
}
}
------解决方案--------------------
class Program
{
static void Main(string[] args)
{
pokeer pk = pokeer.GetIntence();
}
}
class pokeer
{
private readonly static object pkLog = new object();
private static pokeer pk = null;
private pokeer()
{
}
public static pokeer GetIntence()
{
if (pk == null)
{
lock (pkLog)
{
if (pk == null)
{
pk = new pokeer();
}
}
}
return pk;
}
}