I have an homework organizing application in which you can save you assignments to a file. I want to be able to, when the users exits, and if the document is modified, prompt to save changes or not. How would I go about calling a function to do this on a person choosing to close (I would know how if they chose 'Exit' from the menu, but I would like to know how to if they choose to click the "X" to close) Also I would like to know the most efficient way of doing this. I was thinking about containing a hash of the information in the file and when exit is chosen compare the hash of the new data to the old. What would you suggest, and how, if hashing is the best idea, would I go about that? Would reading the information into a stream and then hashing the stream be the best, or creating a temporary file and hashing it be the best way. Thank you for your time and GOD Bless.
Thats another idea I was thinking about, every time you press the next or previous buttons to browse the entries, the values are saved to variable. I was thinking about when you press either button, check to see if the new value is different, setting the flag to true (that the file is modified). I was wondering if I doing those comparisons would be best put into a thread.
Why would you put them into a thread of their own?
Unless you have some complex action to take on it becoming known a file has been modified (but not yet saved) it's not needed. If it is, a notification event queue is the best way where you can indeed have a thread read the queue, but this is likely overly complex. A Map of Booleans (with an entry per opened file) is far simpler.