如何在事件处理程序委托中删除自己??
像这样的代码
void timerTick(object sender, EventArgs e)
{
if (!IsHolding){
return;
}
UtilityStoryboardManager.PlayerStoryboard("End", (_) =>{
IsHolding = false;
//call some function or perform some logic
timer.Stop();
//How Can a eventhandler delegate remove itself ??
//timer.Tick -= timerTick;
}, null);
}
答案 0 :(得分:0)
你想做这样的事吗?
void timerTick(object sender, EventArgs e)
{
if (!IsHolding){
return;
}
UtilityStoryboardManager.PlayerStoryboard("End", (_) =>{
IsHolding = false;
//call some function or perform some logic
timer.Stop();
//How Can a eventhandler delegate remove itself ??
//timer.Tick -= timerTick;
}, null);
(sender as Timer).Tick-=timerTick; // removes the event
}