Performing Streaming on a Separate Thread

The previous example is intended to demonstrate how data streaming would be performed on the same thread as the application. The main application code and the data reading/streaming process all happen sequentially and synchronously within the same thread, and control does not return to the main application loop until reading is complete. However, it may be desirable to have the data read from the file asynchronously, independent of application processing. This would allow the user to interact with the application in a normal fashion, while data is still being streamed from the file which may be local, or could be coming in via a slower intranet or internet connection.

This can be supported by performing the reading on a thread which is separate from the main application thread. After this thread reads in data of a user-specified size, it would post a message to the main application event loop indicating that it has a new chunk of data ready for processing. Then, the main application loop would pass that data to the ParseBuffer function for processing and subsequent insertion into your application database or custom graphics data structures.

Creation of a separate thread and posting a message to the main application loop involves platform and graphical user-interface (GUI) specific logic.

top_level:2 prog_guide:2 prog_guide/base_stream:1