I have a windows forms application consisting of a single form which parses a large body of text upon clicking a few buttons.
There is a huge chunk of code which parses through every node of an XML file, typically around 5000 nodes containing 20-ish child nodes, and those have even more children, and so on and so forth, just to create an image of the file's size.
While iterating through the code, as in when the data is being parsed, if I press the minimize button, it won't minimize but goes into the "not responding" state. My guess is that the minimize function can't be processed while the data is being parsed.
Is there a way to set an interrupt to the minimize/maximize/close buttons, or set priority to them, or any other solution to enable smooth minimisation of the form?
Thanks in advance
Since you are parsing your XML in your main thread, the GUI can't update until the parsing is finish. The best option is to use the BackgroundWorker. It will start an other thread that permit you to execute the parsing of your file while leaving the GUI responsive to the user input.