111,095
社区成员




public DialogBase(int autoCloseDuration)
{
this.InvokeOperator<DialogBase>(s =>
{
this.RunningTime = autoCloseDuration;
this.messageBoxResult = MessageBoxResult.None;
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if (Application.Current != null && Application.Current.MainWindow != this && Application.Current.MainWindow.IsLoaded)
{
this.Owner = Application.Current.MainWindow;
}
if (autoCloseDuration > 0)
{
autoCloseTimer = new Timer();
autoCloseTimer.Interval = 1000;
autoCloseTimer.Elapsed += new ElapsedEventHandler(Elapsed);
autoCloseTimer.Start();
}
});
}
private void Elapsed(object sender, ElapsedEventArgs e)
{
this.InvokeOperator<DialogBase>(s =>
{
this.RunningTime--;
if (RunningTime <= 0)
{
this.Close();
autoCloseTimer.Close();
}
});
}
2. 规定时间没有响应,先直接释放license,给用户一个自动关闭的确认的提示框,提示用户时候要重新连接,并且实现重新连接的方法给用户确认重新连接时调用,用户点取消或者超时直接退出系统