简体   繁体   中英

C# Forms Application, killing task in new window with standard button

we have a programm where you can calculate several points (x/y). afterwards you can draw the graph by clicking at a "draw" button. (chart object) The graph is shown in a new window so there is a close button that allows you to close it again and also killing the task. But there is also this standard cross button in the right corner of the new window's frame. If you click the standard cancel button instead of our own, the window is also closed but the task for the new window is still running in background. Is there a proper way to also kill the task with the standard button?

Thanks ahead!

You could use the FormClosing Event. In that event you can then kill the task. Example:

private void Form1_FormClosing(Object sender, FormClosingEventArgs e) {
// Do your closing here:
}

Here is a link: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosing(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM