0
发射时不止一次我有我registred使用Autofac像活动使用Autofac
builder.RegisterAssemblyTypes(assembly)
.AssignableTo<Form>()
.As<IMyForm, MyForm>()
.AsImplementedInterfaces();
一切形式工作正常,但当我加Load事件MyForm的东西坏了happend。如果我第一次打开MyForm加载事件被触发,但如果我打开它不止一次加载事件也会被触发多次。为了防止我添加OnClosing方法,看起来像那样
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
Load -= MyForm_Load;
}
有没有更好的方法来做到这一点?