I'm writing a simple encryptor program. When I type in the first textbox the encrypted text appears on the second textbox on the fly using the textchanged event. I also have a button to load key files. My problem is if I type first in to the textbox and then load a keyfile afterwards the encrypting handler is not called, because it's hooked to the textchanged event, and I have to write something to the first textbox to invoke it.
To solve this I hooked 2 events to the load button's click event, one is loading the key file, and the other is the same that is hooked to the textchanged event. (I would really like to avoid code duplication.)
This is working correctly, but how can I be sure, that everytime the key file loading happens and finishes before the encrypting function is called? Is there a better way to do this?