MCS 260 Fall 2021
Emily Dumas
The password generator application relies on a single function to generate a random password meeting certain specifications.
What if that function was slow?
Even if that's not realistic in this case, many GUI applications need to perform actions of long or uncertain duration.
The GUI is unresponsive while the program is waiting for password generation to finish.
In addition to being a bad user experience, this can cause all sorts of problems.
Move the slow part to a separate "worker" thread.
Worker thread waits for signal that work is needed.
Main thread uses a threading.Event
to signal it.
Main thread runs the GUI and remains responsive even if the worker is busy.
The producer-consumer pattern, with a queue, is useful if every piece of work dispatched by the main thread needs to be done.
But in this case, we only ever want to work on the most recent request for an update, ignoring any older ones that didn't get processed.
print("Have a good winter break!")
mcs260.exit(0)