| title | How to: Send a Message at a Regular Interval | Microsoft Docs | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||
| ms.date | 11/04/2016 | |||||||||
| ms.reviewer | ||||||||||
| ms.suite | ||||||||||
| ms.technology |
|
|||||||||
| ms.tgt_pltfrm | ||||||||||
| ms.topic | article | |||||||||
| dev_langs |
|
|||||||||
| helpviewer_keywords |
|
|||||||||
| ms.assetid | 4b60ea6c-97c8-4d69-9f7b-ad79f3548026 | |||||||||
| caps.latest.revision | 19 | |||||||||
| author | mikeblome | |||||||||
| ms.author | mblome | |||||||||
| manager | ghogen | |||||||||
| translation.priority.ht |
|
|||||||||
| translation.priority.mt |
|
This example shows how to use the concurrency::timer class to send a message at a regular interval.
The following example uses a timer object to report progress during a lengthy operation. This example links the timer object to a concurrency::call object. The call object prints a progress indicator to the console at a regular interval. The concurrency::timer::start method runs the timer on a separate context. The perform_lengthy_operation function calls the concurrency::wait function on the main context to simulate a time-consuming operation.
[!code-cppconcrt-report-progress#1]
This example produces the following sample output:
Performing a lengthy operation..........done.
Copy the example code and paste it in a Visual Studio project, or paste it in a file that is named report-progress.cpp and then run the following command in a Visual Studio Command Prompt window.
cl.exe /EHsc report-progress.cpp
Asynchronous Agents Library
Asynchronous Message Blocks
Message Passing Functions