In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to understand the C# form closing event". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. The first step
2. Step 2
After the name is named, double-click the name to edit the event, and if you can't find it, you can go to the .cs file and check it for yourself.
Private void frmMom_FormClosing (object sender, FormClosingEventArgs e) {DialogResult result = MessageBox.Show ("are you sure you want to close it!" , "prompt message", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result = = DialogResult.OK) {Console.WriteLine ("1"); e.Cancel = false; / / Click OK} else {Console.WriteLine ("2"); e.Cancel = true Finally, you can check the file of the design designer.cs to see if it is correct.
This.FormClosing + = new System.Windows.Forms.FormClosingEventHandler (this.frmMom_FormClosing)
This.frmMom_FormClosing can't have the same name as FormClosing or report an error. Remember.
Another property is FormClosed, which is used for the method you want to execute after closing the page, such as shutting down a service after closing the page.
C # uses multithreading, how to close all threads of the form when closing the form to make the program exit.
This.Close (); just close the current window. If it is not the main form, you cannot exit the program, and if there is a managed thread (non-main thread), you cannot exit cleanly.
Application.Exit (); forces all messages to abort and exits all forms, but cannot exit cleanly if there is a managed thread (non-main thread)
Application.ExitThread (); force to abort all messages on the calling thread, but also face the problem that other threads cannot exit correctly
System.Environment.Exit (0); this is the most thorough way to exit. No matter what thread is forced to exit, the program ends cleanly.
Thread_VIEW.Abort (); close the Thread_VIEW thread
Thread_SAVE.Abort (); close the Thread_SAVE thread
So much for the content of "how to understand the C# form close event". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.