c# - How do I get custom dialog close without showing graphics artifacts? -
I have a custom window model form with the following event code:
private void BtnCancel_Click (object sender, event events e) {Close (); _result = DialogResult.OK; }
The problem occurs when I click OK, which triggers some process-deep content (report generation) and is taken partially on the form screen. This report is taking precedence over the window fresh like the generation. Do I have to do something else to make it disappear before the process-intensive code? It will definitely annoy my users.
Edit # 1:
I am trying to work on the trigger method and passing the Shodiogyog in the dialog owner. For my case, the calling method is not a form. Therefore, I am trying to create IWin32Owner from the main window handle of the process so that I can pass it in the ShowDialog method.
public class WindowWrapper: System.Windows.Forms.IWin32Window {public WindowWrapper (IntPtr handle) {_hwnd = handle; } Public IntPtr handle {get {return _hwnd; }} Private IntPtr _hwnd; } // Calling Method ShowDialog (New WindowDrive (System.Digagnostics.Process.GetCurrentProcess (. MainWindowHandle));
However, the correspondent is still not set to ShowDialog after calling. I stepped in the window print and the handle is non-zero. How to get the active form of the present process, even more thoughts about it?
Edit # 2 Now I am using the following owner to retrieve the active form and then calling the owner. Click ().
Public stable form GetActiveForm () An empty form return form for an MDI app is activated = form. ActiveForm; If (activeForm == zero) {FormCollection openForms = Application.OpenForms; For (int i = 0; i
Do not process-intensive code on the clear answer UI thread. <
Added
If you insist on doing it on the UI thread, you can use it. owner. After starting, execute the code after closing it.
Comments
Post a Comment