定期发送消息
来源:互联网 发布:js 展开折叠 section 编辑:程序博客网 时间:2024/06/07 01:04
摘自 http://msdn.microsoft.com/zh-cn/library/dd728065(v=vs.110).aspx
本示例演示如何使用 concurrency::timer 定期时间间隔发送消息的类。
下面的示例使用 timer 对象报告长时间操作的进度。 此示例的链接timer对象的 concurrency::call 对象。 call 对象定期将进度指示器输出到控制台。Concurrency::timer::start 方法上不同于运行计时器。 perform_lengthy_operation函数调用 concurrency::wait 上主上下文来模拟需要较长时间的函数。
C++
// report-progress.cpp// compile with: /EHsc#include <agents.h>#include <iostream>using namespace concurrency;using namespace std;// Simulates a lengthy operation.void perform_lengthy_operation(){ // Yield the current context for one second. wait(1000);}int wmain(){ // Create a call object that prints a single character to the console. call<wchar_t> report_progress([](wchar_t c) { wcout << c; }); // Create a timer object that sends the dot character to the // call object every 100 milliseconds. timer<wchar_t> progress_timer(100, L'.', &report_progress, true); wcout << L"Performing a lengthy operation"; // Start the timer on a separate context. progress_timer.start(); // Perform a lengthy operation on the main context. perform_lengthy_operation(); // Stop the timer and print a message. progress_timer.stop(); wcout << L"done.";}
此示例产生下面的示例输出:
Performing a lengthy operation..........done.
将示例代码复制并将其粘贴在 Visual Studio 项目中,或将它粘贴到一个文件,名为报告 progress.cpp ,然后在 Visual Studio 命令提示符窗口中运行以下命令。
cl.exe /EHsc report-progress.cpp
0 0
- 定期发送消息
- Redis源码解析:21sentinel(二)定期发送消息、检测主观下线
- 消息发送
- 发送消息
- 发送消息
- XMPP 发送消息,发送图片
- ios发送消息 注册消息
- 解决Bugfree不能定期发送统计邮件的问题
- 定期自动备份SVN版本并发送致邮箱中
- AODV路由维护(定期发送Hello和链路层反馈)
- Spring Quartz结合Spring mail定期发送邮件
- 如何实现脚本每周几定期发送邮件?
- 向线程发送消息
- sendmessage 发送消息
- MDI发送消息
- 调用CMD发送消息
- QQ消息发送器
- 发送广播消息zz
- 9.HTML5 javascript
- NYOJ 286 动物统计
- 一举两得
- 终端运行sublime的方法
- oracle字符串连接及months_between函数
- 定期发送消息
- c++ windows下命令行一种解析方式,linux下命令行解析例子
- 一周极客热文:十步完全理解SQL
- 使用消息块筛选器
- Android获取内部和SDCard的存储空间
- StreamTokenizer
- OnOK()、OnCancel()()、OnClose()、OnDestroy()
- Android图片二进制与Bitmap、Drawable之间的转换
- oracle11g更改字符集AL32UTF8为ZHS16GBK