XLL+ Class Library

MtBackground sample

Functionality

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.

Running the sample

The sample files are provided in pre-built form in the Samples/Bin sub-directory. To run a sample, follow these steps:

  1. Open Samples/Bin/MtBackgroundGui.xla.
  2. Open Samples/Bin/MtBackgroundDemo.xls.
  3. Observe that the data in some formula fields changes periodically.
  4. Try changing formulae, and moving them around the workbook.
  5. Use the options on the MtBackground menu to start and stop the live data, and to change its frequency.

Content

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.

Next: MtBackground.h >>