青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

山寨:不是最好的,是最適合我們的!歡迎體驗山寨 中文版MSDN

Blog @ Blog

當華美的葉片落盡,生命的脈絡才歷歷可見。 -- 聶魯達

常用鏈接

統計

積分與排名

BBS

Blog

Web

最新評論

如何正確的使用PeekMessage()

HOWTO: How to Use PeekMessage() Correctly in Windows

SUMMARY

In the Windows environment, many applications use a PeekMessage() loop to perform background processing. Such applications must allow the Windows system to enter an idle state when their background processing is complete. Otherwise, system performance, "idle-time" system processes such as paging optimizations, and power management on battery-powered systems will be adversely affected.

While an application is in a PeekMessage() loop, the Windows system cannot go idle. Therefore, an application should not remain in a PeekMessage() loop after its background processing has completed.

NOTE: The PeekMessage method described in this article is only needed if your application is a 32-bit application for Windows and is, for some reason, unable to create threads and perform background processing.

MORE INFORMATION

Many Windows-based applications use PeekMessage() to retrieve messages while they are in the middle of a long process, such as printing, repaginating, or recalculating, that must be done "in the background." PeekMessage() is used in these situations because, unlike GetMessage(), it does not wait for a message to be placed in the queue before it returns.

An application should not call PeekMessage() unless it has background processing to do between the calls to PeekMessage(). When an application is waiting for an input event, it should call GetMessage() or WaitMessage().

Remaining in a PeekMessage() loop when there is no background work causes system performance problems. A program in a PeekMessage() loop continues to be rescheduled by the Windows scheduler, consuming CPU time and taking time away from other processes.

In enhanced mode, the Virtual Machine (VM) in which Windows is running will not appear to be idle as long as an application is calling the PeekMessage function. Therefore, the Windows VM will continue to receive a considerable fraction of CPU time.

Many power management methods employed on laptop and notebook computers are based on the system going idle when there is no processing to do. An application that remains in a PeekMessage() loop will make the system appear busy to power management software, resulting in excessive power consumption and shortening the time that the user can run the system.

In the future, the Windows system will make more and more use of idle time to do background processing, which is designed to optimize system performance. Applications that do not allow the system to go idle will adversely affect the performance of these techniques.

All these problems can be avoided by calling the PeekMessage() function only when there is background work to do, and calling GetMessage() or WaitMessage() when there is no background work to do.

For example, consider the following PeekMessage() loop. If there is no background processing to do, this loop will continue to run without waiting for messages, preventing the system from going idle and causing the negative effects described above.
   // This PeekMessage loop will NOT let the system go idle.
   for( ;; )
   {
      while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
      {
         if (msg.message == WM_QUIT)
            return TRUE;
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
      BackgroundProcessing();
    }
This loop can be rewritten in two ways, as shown below. Both of the following PeekMessage() loops have two desirable properties:

They process all input messages before performing background processing, providing good response to user input.
The application "idles" (waits for an input message) when no background processing needs to be done.
 

Improved PeekMessage Loop 1

   // Improved PeekMessage() loop
   for(;;)
   {
      while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
      {
         if (msg.message == WM_QUIT)
            return TRUE;
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
      if (IfBackgroundProcessingRequired())
         BackgroundProcessing();
      else
         WaitMessage(); // Will not return until a message is posted.
   }	

Improved PeekMessage Loop 2

   // Another improved PeekMessage() loop
   for (;;)
   {
      for (;;)
      {
         if (IfBackgroundProcessingRequired())
         {
            if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
               break;
         }
         else
            GetMessage(&msg, NULL, 0, 0, 0);
         if (msg.message == WM_QUIT)
            return TRUE;
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
      BackgroundProcessing();
   }		
Note that calls to functions such as IsDialogMessage() and TranslateAccelerator() can be added to these loops as appropriate.

There is one case in which the loops above need additional support: if the application waits for input from a device (for example, a fax board) that does not send standard Windows messages. For the reasons outlined above, a Windows-based application should not use a PeekMessage() loop to continuously poll the device. Rather, implement an Interrupt Service Routine (ISR) in a Dynamic-Link Library (DLL). When the ISR is called, the DLL can use the PostMessage function to inform the application that the device requires service. DLL functions can safely call the PostMessage() function because the PostMessage() function is reentrant.

posted on 2008-01-19 16:12 isabc 閱讀(2911) 評論(0)  編輯 收藏 引用 所屬分類: VC Function

廣告信息(免費廣告聯系)

中文版MSDN:
歡迎體驗

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产情人节一区| 国产精品亚洲欧美| 亚洲天堂久久| 一本一本久久a久久精品综合妖精| 欧美激情一区二区三区四区 | 欧美一区=区| 亚洲美女91| 91久久国产综合久久91精品网站| 久久免费精品日本久久中文字幕| 久久精品盗摄| 免费看亚洲片| 亚洲区免费影片| 亚洲一本大道在线| 欧美专区福利在线| 欧美成熟视频| 国产精品va在线播放| 国产精品每日更新在线播放网址| 国产日韩欧美高清免费| 国语精品一区| 亚洲精品一区二区三区四区高清 | 嫩草成人www欧美| 欧美日韩免费一区二区三区| 国产噜噜噜噜噜久久久久久久久| 极品日韩久久| 亚洲无吗在线| 欧美jizz19hd性欧美| 一本久久青青| 免费观看30秒视频久久| 国产精品亚洲网站| 日韩亚洲精品在线| 久久久www成人免费无遮挡大片| 亚洲国产精品www| 亚洲欧美激情一区二区| 欧美国产精品专区| 国产在线播放一区二区三区| 一区二区三欧美| 免费人成网站在线观看欧美高清| 在线视频欧美日韩| 欧美不卡视频一区| 激情综合视频| 欧美一区二区三区喷汁尤物| 亚洲精品日韩久久| 久久综合狠狠| 国产伪娘ts一区| 亚洲综合电影| 亚洲免费观看高清完整版在线观看熊| 久久久国产午夜精品| 国产精品美女午夜av| 一区二区日韩精品| 亚洲国产精品成人综合色在线婷婷 | 欧美成人精品三级在线观看| 亚洲欧美色一区| 欧美日韩一区精品| 亚洲激精日韩激精欧美精品| 欧美一区日韩一区| 中文网丁香综合网| 欧美美女bbbb| 午夜久久久久久| 国产精品扒开腿做爽爽爽软件| 国产亚洲女人久久久久毛片| 中国亚洲黄色| aaa亚洲精品一二三区| 欧美激情一区二区久久久| 狠狠久久亚洲欧美专区| 久久久青草青青国产亚洲免观| 亚洲一区二区三区四区中文| 欧美日韩情趣电影| 亚洲图片你懂的| 亚洲视频日本| 欧美视频一区二区| 一本色道久久精品| 一区二区激情| 国产欧美一区二区精品婷婷| 久久免费高清视频| 久久久免费精品| 狠狠色综合网站久久久久久久| 久久综合久久美利坚合众国| 久久中文字幕一区| 日韩亚洲综合在线| 中日韩视频在线观看| 国产欧美日韩不卡| 久久精品在这里| 久久亚洲综合网| 亚洲精品日韩激情在线电影| 在线亚洲精品| 国产有码一区二区| 亚洲欧洲一区二区三区| 欧美性猛交xxxx乱大交蜜桃| 欧美一级成年大片在线观看| 久久久久久自在自线| 亚洲美女黄网| 午夜欧美大尺度福利影院在线看| 精品999在线观看| 亚洲精品一区在线观看香蕉| 国产精品一区二区a| 久久久欧美精品| 欧美激情精品久久久六区热门| 亚洲女人小视频在线观看| 欧美在线视频日韩| 日韩视频免费观看高清在线视频| 一本色道久久88综合亚洲精品ⅰ| 国产日韩精品在线观看| 亚洲电影免费观看高清| 国产精品一区二区你懂得| 欧美电影在线观看| 国产精品免费区二区三区观看| 美女免费视频一区| 欧美日本在线观看| 另类av一区二区| 欧美日韩在线播放| 麻豆精品国产91久久久久久| 欧美精品激情在线观看| 久久国产视频网站| 欧美日韩在线视频一区| 欧美黄在线观看| 国产精品视频一二| 亚洲久久视频| 亚洲全部视频| 亚洲国产精品久久久久秋霞不卡| 亚洲在线观看免费视频| 久久一区欧美| 久久成人一区二区| 欧美日韩国产欧美日美国产精品| 美女久久网站| 国产一区清纯| 亚洲综合欧美日韩| 亚洲一区二区三区在线视频| 免费不卡亚洲欧美| 久久日韩精品| 国产亚洲精品激情久久| 在线综合+亚洲+欧美中文字幕| 亚洲大片在线| 久久久夜夜夜| 久久久夜色精品亚洲| 国产精品免费小视频| 一区二区不卡在线视频 午夜欧美不卡在 | 午夜亚洲福利在线老司机| 一区二区三区欧美日韩| 欧美高清你懂得| 亚洲激情视频网| 亚洲精品黄色| 欧美精品色网| 亚洲免费观看在线观看| 亚洲视频一区二区| 欧美三级视频在线观看| 一本色道久久综合亚洲精品按摩| 亚洲免费观看高清完整版在线观看熊| 老司机免费视频久久| 欧美大尺度在线| 亚洲高清免费| 欧美激情视频一区二区三区免费| 亚洲精品午夜| 亚洲女同精品视频| 国产一区二区三区精品欧美日韩一区二区三区 | 亚洲国产cao| 日韩视频一区二区三区| 欧美另类专区| 亚洲午夜激情在线| 久久精品一级爱片| 亚洲第一精品久久忘忧草社区| 麻豆成人在线观看| 亚洲全部视频| 久久精品亚洲国产奇米99| 国产真实乱偷精品视频免| 玖玖综合伊人| 一区二区三区精品视频在线观看| 欧美一区二区在线看| 精品成人国产在线观看男人呻吟| 免费观看亚洲视频大全| 国产精品人人做人人爽人人添| 99re热这里只有精品视频 | 欧美三级电影网| 亚洲免费一级电影| 蜜臀久久99精品久久久久久9| 亚洲欧洲日本mm| 国产精品视频免费在线观看| 久久一区二区三区超碰国产精品| 亚洲精品视频二区| 久久久久久伊人| 洋洋av久久久久久久一区| 国产亚洲欧美在线| 欧美精品在线观看91| 欧美一级视频精品观看| 亚洲三级电影全部在线观看高清| 欧美一区国产一区| 亚洲免费高清视频| 曰本成人黄色| 国产欧美一区二区色老头| 欧美激情综合色| 久久9热精品视频| 一区二区日韩欧美| 亚洲丰满少妇videoshd| 久久精品一本| 午夜伦理片一区| 在线一区二区三区四区五区| 亚洲电影第三页| 韩国av一区| 国产亚洲欧美日韩精品| 国产噜噜噜噜噜久久久久久久久 | 在线观看日韩www视频免费|