The MtBackground sample is the simplest of the multithreaded sample applications. It provides three real-time data services, via a single add-in function, MtbGet(Topic).
Topic | Description |
---|---|
mem | Current total amount of memory in use |
C:\, D:\ etc | Amount of space available on a local fixed drive |
one, two, three, or four | A random number, periodically changed |
The add-in runs a single background thread, which periodically checks the system status, and generates new random numbers, and posts them to the main thread.
The sample files are provided in pre-built form in the Samples/Bin sub-directory. To run a sample, follow these steps:
The following source files are of interest:
MtBackground.h | Class definitions | |
MtBackgroundThread.cpp | The background thread and all the functions it uses | |
MtBackground.cpp | C++ implementation of add-in | |
MtBackgroundGui.xla | User interface add-in |
We will examine each in turn.