对话框Dialog1,上有一个确定按钮:
- Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
- Me.DialogResult = System.Windows.Forms.DialogResult.OK
- Me.Close()
- End Sub
命令函数调用对话框,点击确定后执行一个比较耗时的操作:
- <CommandMethod("TTT")> Public Sub TTT()
- Dim doc As Document = Application.DocumentManager.MdiActiveDocument
- Dim ed As Editor = doc.Editor
- Dim Dlg As New Dialog1
- Application.ShowModalDialog(Dlg)
- If Dlg.DialogResult = Windows.Forms.DialogResult.OK Then
- For i = 0 To 30000
- ed.WriteMessage(vbLf & "i={0}", i)
- Next
- End If
- End Sub
问题:点击确定按钮后,对话框直到命令函数执行完成才消失。VBA中用DoEvents方法可以实现,VB.NET中DoEvents方法不起作用。如果Click事件加上Me.Hide,则命令执行时很多AutoCAD界面元素时不显示,也不行。
怎么才能让对话框即时关闭不延迟?
|