A loop like the one used in the previous example is an ideal task to run in an independent thread. That way, we could keep control over the UI and have the possibility of canceling the job, displaying its progress, hiding the CodeBreaker controls, and displaying our Fishes game. Hence, we can avoid being shot by the guard (death or jail).
In this section, we will see how to use the
BackgroundWorker component in a simple way to create a second concurrent thread in our application, which will allow the user to perform other actions while the CodeBreaking process is being performed.
We will first do this in an asynchronous way and then in a synchronous way in the next chapter. The differences will be ...