问题描述
我正在尝试取消订阅另一个事件中的一个事件,但我不知道我应该如何处理这个事件,或者是否有一个简单的模式。我已经查看了 Microsoft 的官方文档,但没有找到任何可以解决我的问题的内容。
private void bTrainingD_Click(object sender,RoutedEventArgs e)
{
System.Windows.Threading.dispatcherTimer timer = new System.Windows.Threading.dispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += new EventHandler(dispatcherTimer_Tick);
timer.Start();
}
...
private void dispatcherTimer_Tick(object sender,EventArgs e)
{
if (true)
{
//some code here
}
else
{
// unsubscribe or stop the Tick-Event here
}
}
感谢您的帮助。 :-)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)