![]() # TODO: wait here for the result to be available before continuing! Thread = threading.Thread(target=background_calculation) # when the calculation is done, the result is stored in a global variable ![]() To show you these wait patterns, I'm going to use an example application, shown below: from random import random I'm going to use Python for all the examples, but the concepts I'm going to present apply to all programming languages. In these and many other situations you will need to figure out a way to make your script wait, and this isn't as easy as it sounds if you want to do it properly! In this article I'm going to show you a few different ways to wait. You may need to wait until another thread finishes, or maybe until a new file appears in a directory on disk that is being watched. For many types of applications, at times it is necessary to pause the running of the program until some external condition occurs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |