내 프로그램 (form1)에서 Form3.ShowDialog()
으로 다른 양식 (form3)을 호출합니다. 이 양식은 진행률 막대로 추적되는 상대적으로 긴 프로세스를 실행합니다. 이 양식에는이 프로세스를 취소하는 버튼이 있으며 (pdf 문서 생성) 프로세스를 되돌릴 수 있습니다. 내가 프로세스를 종료하고 백업을 사용하여 변경 내용을 되돌리려이 버튼을 싶습니다MsgBox가 양식을 닫습니다
Private Sub annulerBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles annulerBtn.Click
If (MsgBox("Êtes-vous sûr de vouloir annuler? Cette reviendra toutes les modifications apportées au document", MsgBoxStyle.YesNo, "annuler l'exportation") = MsgBoxResult.Yes) Then
_cancel = True
doc.Close() 'close pdf'
fs.Close() 'close stream'
If (_done And _backup) Or (Not _done And _backup) Then
'revert file from backup if backup exists'
System.IO.File.Delete(_path)
IO.File.Copy("C:\temp\temp.pdf", _path)
IO.File.Delete("C:\temp\temp.pdf")
Else
'otherwise simply delete the new file'
System.IO.File.Delete(_path)
End If
Me.Close()
Else
'continue with the form!!'
End If
End Sub
다음과 같이 취소 버튼 (form3)에 대한
코드입니다.
현재 사용자 입력을 계속하려면 프로세스 내에서 Application.DoEvents()
을 사용하여 멀티 스레딩 및 인스턴트 메신저에서 멀리하고 있습니다.
사용자가 예 버튼을 누르면 기능이 예상대로 작동합니다. 그러나 사용자가 아니오를 누르면 프로세스가 예상대로 계속되지만 양식은 나중에 닫힙니다.
디버깅을하면 사용자가 no를 누르면 Me.Close()
또는 Form3.Close()
을 호출하지 않습니다.
이 문제에 대한 도움을 주시면 감사하겠습니다. 감사합니다.
편집
:이 옳다면 여기이 호출 스택App58.exe!App58.Form3.Form3_FormClosing(Object sender = {App58.Form3}, System.Windows.Forms.FormClosingEventArgs e = {System.Windows.Forms.FormClosingEventArgs}) Line 432 Basic
System.Windows.Forms.dll!System.Windows.Forms.Form.OnFormClosing(System.Windows.Forms.FormClosingEventArgs e) + 0x77 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.CheckCloseDialog(bool closingOnly = false) + 0x8c bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FContinueMessageLoop(int reason, int pvLoopData, System.Windows.Forms.NativeMethods.MSG[] msgPeeked) + 0x160 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = 4, int pvLoopData = 0) + 0x1ae bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = 4, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.Application.ModalApplicationContext}) + 0x177 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.RunDialog(System.Windows.Forms.Form form) + 0x33 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog(System.Windows.Forms.IWin32Window owner) + 0x370 bytes
System.Windows.Forms.dll!System.Windows.Forms.Form.ShowDialog() + 0x7 bytes
App58.exe!App58.Form1.RB_pdf_Click(Object sender = {Text = "Exporter PDF"}, System.EventArgs e = {System.Windows.Forms.MouseEventArgs}) Line 1994 + 0xa bytes Basic
원하는 것을 분명하지 않으면 문제를 표현하는 것이 어렵다고 생각하지 않습니다.이게 무엇입니까? '? 그리고'form'은 무엇을 참조합니까? ... 문제를 다시 말하십시오. –
가장 중요한 코드를 주석 처리했습니다. 기본적인 디버깅 전략은 FormClosing 이벤트 핸들러를 추가하고 여기에 중단 점을 설정하는 것입니다. 호출 스택을보고 거기에 도달했는지 확인하십시오. –
그래서 사용자가 '아니요'를 눌러도 'Me.Close()'를 호출하겠습니까? –