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

山寨:不是最好的,是最適合我們的!歡迎體驗山寨 中文版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 閱讀(2914) 評論(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>
            欧美mv日韩mv国产网站| 欧美中文字幕在线播放| 国产亚洲福利社区一区| 久久综合九色| 久久九九热免费视频| 亚洲欧美日韩天堂| 亚洲五月婷婷| 亚洲黄色片网站| 欧美风情在线观看| 免费不卡在线观看| 欧美国产日韩二区| 欧美国产日韩精品| 米奇777在线欧美播放| 美腿丝袜亚洲色图| 亚洲精品国产拍免费91在线| 免费在线播放第一区高清av| 欧美激情精品久久久久| 最新69国产成人精品视频免费| 欧美刺激午夜性久久久久久久| 欧美不卡视频一区发布| 亚洲国产另类久久久精品极度| 欧美成人免费网| 99成人在线| 久久久久网站| 欧美成人国产| 国产精品久久久久久久久久久久| 国户精品久久久久久久久久久不卡 | 国产精品视频大全| 一区二区在线观看视频| 亚洲尤物影院| 影音先锋亚洲电影| 日韩视频在线你懂得| 欧美在线观看你懂的| 欧美成人资源网| 性欧美暴力猛交另类hd| 欧美日韩视频在线第一区| 亚洲第一色中文字幕| 久久久久国产成人精品亚洲午夜| 亚洲黄色免费电影| 久久综合国产精品| 伊人久久大香线蕉综合热线| 久久久五月天| 欧美影院在线| 在线成人激情黄色| 欧美顶级大胆免费视频| 久久欧美中文字幕| 一区二区在线看| 欧美96在线丨欧| 久久精品国产精品亚洲精品| 国产精品视频1区| 亚洲欧美中文日韩v在线观看| 一本色道久久综合亚洲精品按摩| 欧美一区激情| 国产精品久在线观看| 午夜一级久久| 久久久久久久激情视频| 亚洲第一精品久久忘忧草社区| 午夜精品福利一区二区蜜股av| 免费不卡欧美自拍视频| 久久综合九色综合久99| 亚洲精品在线观看视频| 国产精品视频一区二区三区 | 欧美成人免费网站| 99视频一区二区三区| 狠狠色香婷婷久久亚洲精品| 老司机精品视频一区二区三区| 久久亚洲二区| 久久高清国产| 国产欧美日韩中文字幕在线| 亚洲男人的天堂在线| 久久综合中文字幕| 亚洲一区二区三区中文字幕| 久久美女艺术照精彩视频福利播放| 99成人免费视频| 久久夜色精品亚洲噜噜国产mv| 亚洲一区二区在线免费观看视频| 国产裸体写真av一区二区| 亚洲毛片在线观看| 亚洲一区国产视频| 亚洲欧洲在线一区| 久久爱www| 久久久激情视频| 国产精品伦理| 亚洲午夜视频在线| 西西人体一区二区| 欧美三级资源在线| 亚洲国产毛片完整版| 亚洲电影第1页| 欧美99久久| 亚洲精品一区二区在线| 一区二区电影免费观看| 欧美三级电影一区| 亚洲在线一区二区三区| 久久久久久电影| 在线日韩电影| 欧美视频在线观看 亚洲欧| 99视频日韩| 久久中文字幕导航| 亚洲无限乱码一二三四麻| 国产在线精品成人一区二区三区| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲精品123区| 欧美日韩国产不卡在线看| 一区二区三区偷拍| 亚洲国产成人av| 久久久久久一区二区| 一本到高清视频免费精品| 国产精品日日摸夜夜摸av| 麻豆国产va免费精品高清在线| 在线一区欧美| 亚洲狠狠丁香婷婷综合久久久| 羞羞答答国产精品www一本| 亚洲欧洲一区二区天堂久久| 国产婷婷色一区二区三区四区| 欧美日韩国产影片| 欧美成人免费播放| 久久先锋影音| 久久中文精品| 欧美xart系列高清| 欧美成人精品高清在线播放| 久久综合狠狠综合久久激情| 亚洲一区二区不卡免费| 欧美顶级大胆免费视频| 亚洲大片免费看| 亚洲电影在线| 亚洲精选国产| 亚洲主播在线观看| 久久中文字幕一区二区三区| 久久综合精品一区| 欧美精品在线播放| 国产精品视频精品视频| 好吊妞**欧美| 99成人在线| 亚洲素人在线| 国产欧美午夜| 国产一区欧美| 国产在线观看91精品一区| 黄色精品一区二区| 亚洲免费观看高清完整版在线观看| 一区二区三区成人| 久久亚洲精品欧美| 亚洲视频日本| 久久深夜福利免费观看| 亚洲欧洲日本国产| 亚洲欧洲99久久| 国产精品大全| 亚洲精品一区二区三区蜜桃久| 欧美一区二区三区久久精品| 欧美激情一区二区三区成人| 亚洲小说欧美另类婷婷| 欧美成人三级在线| 亚洲国产清纯| 女人天堂亚洲aⅴ在线观看| 亚洲高清二区| 新片速递亚洲合集欧美合集| 欧美人体xx| 一本久道久久久| 美女免费视频一区| 久久久久久久欧美精品| 国户精品久久久久久久久久久不卡 | 久久久777| 一区国产精品| 亚洲福利视频一区| 欧美精品免费在线观看| aa级大片欧美三级| 亚洲一区不卡| 国产精品毛片a∨一区二区三区| 亚洲最新合集| 午夜亚洲福利| 亚洲乱码一区二区| 日韩亚洲欧美一区| 国产美女精品在线| 欧美成人免费一级人片100| 欧美日韩国产精品一卡| 久久久精品日韩欧美| 免费观看国产成人| 性做久久久久久免费观看欧美| 久久成人免费网| 一区二区三区视频在线| 欧美一区国产一区| 亚洲在线观看免费| 久久日韩精品| 欧美久久在线| 欧美一级播放| 欧美屁股在线| 久久这里有精品15一区二区三区| 欧美日韩免费一区二区三区| 久久中文精品| 国产一区99| 小处雏高清一区二区三区| 亚洲一二三区精品| 欧美成人dvd在线视频| 久久亚洲国产精品日日av夜夜| 国产精品高清在线| 亚洲欧美色婷婷| 亚洲日本无吗高清不卡| 久久一区二区视频| 久久综合综合久久综合| 狠狠色丁香婷综合久久| 久久免费视频这里只有精品|