• <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>
            <2006年9月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            1234567

            統(tǒng)計

            • 隨筆 - 24
            • 文章 - 0
            • 評論 - 17
            • 引用 - 0

            常用鏈接

            留言簿(4)

            隨筆分類

            隨筆檔案

            相冊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            定時器處理函數(shù)TimerProc會不會重入?
            我覺得不會。另外,我在編程中也似乎從來沒考慮過重入的問題。

            證明如下:
            ?1//?testtimer.cpp?:?定義控制臺應(yīng)用程序的入口點。
            ?2//
            ?3
            ?4#include?"stdafx.h"
            ?5#include?<windows.h>
            ?6#include?<conio.h>
            ?7
            ?8static?UINT?idTimer?=?0;
            ?9static?int?reentry?=?0;
            10static?int?call_cnt?=?0;
            11
            12void?LengthyWork(void)
            13{
            14????//Sleep(3000);
            15????int?i?=?0,j?=?0;
            16????for(i;i?<?50000;)?{
            17????????i++;
            18????????for(j?=?i;j?>?0;)?{
            19????????????j--;
            20????????}

            21????}

            22
            23}

            24VOID?CALLBACK?OnTimer(HWND?hwnd,
            25????UINT?uMsg,
            26????UINT_PTR?idEvent,
            27????DWORD?dwTime
            28)
            29{
            30????++call_cnt;
            31????printf("entry(%d)??reentry:%d\n",call_cnt,reentry);
            32????++reentry;
            33????LengthyWork();
            34????--reentry;
            35????printf("exit(%d)???reentry:%d\n",call_cnt,reentry);
            36}

            37int?_tmain(int?argc,?_TCHAR*?argv[])
            38{
            39????idTimer?=?SetTimer(NULL,0,1000,OnTimer);
            40????int?ret?=?0;
            41????MSG?msg;
            42????while(1)?{
            43????????if(kbhit())?{
            44????????????return?0;
            45????????}

            46????????ret?=?GetMessage(&msg,NULL,0,0);
            47????????if(ret)?{
            48????????????TranslateMessage(&msg);
            49????????????DispatchMessage(&msg);
            50????????}

            51????}

            52????return?0;
            53}

            54

            一次執(zhí)行結(jié)果如下:
            entry(1)? reentry:0
            exit(1)?? reentry:0
            entry(2)? reentry:0
            exit(2)?? reentry:0
            entry(3)? reentry:0
            exit(3)?? reentry:0
            entry(4)? reentry:0
            exit(4)?? reentry:0

            posted on 2006-09-01 14:48 小蔥蘸醬 閱讀(1825) 評論(1)  編輯 收藏 引用

            評論

            # re: 定時器處理函數(shù)TimerProc會不會重入? 2012-02-06 19:16 千里馬雕刻師傅

            會重入的,你把SetTimer(NULL,0,1000,OnTimer)改成
            SetTimer(NULL,0,1,OnTimer)試試
              回復(fù)  更多評論    

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            91久久精一区二区三区大全| 99久久综合国产精品二区| 日本高清无卡码一区二区久久| 国产三级观看久久| 久久精品国产亚洲AV久| 国内精品久久人妻互换 | 要久久爱在线免费观看| 99久久国产免费福利| 久久久久这里只有精品| 久久精品亚洲中文字幕无码麻豆| 国产成人精品久久二区二区| 欧美与黑人午夜性猛交久久久| 久久精品www人人爽人人| 久久露脸国产精品| 99久久777色| 亚洲午夜久久久久久久久电影网| 久久99精品国产99久久| 亚洲国产美女精品久久久久∴| 久久精品视频网| 久久精品亚洲日本波多野结衣| 久久亚洲电影| 九九热久久免费视频| 久久99热只有频精品8| 久久久久久国产精品无码下载| 青青青伊人色综合久久| 久久夜色精品国产噜噜噜亚洲AV| 精品久久久久久无码中文字幕| 97久久综合精品久久久综合| 久久亚洲精品无码aⅴ大香| 久久综合视频网站| 久久午夜综合久久| 久久国产影院| 国内精品免费久久影院| 国产精品久久久久久久午夜片| 99久久超碰中文字幕伊人| 国产精品18久久久久久vr| 久久精品国产亚洲AV无码娇色 | 国产一区二区精品久久岳| 99久久精品免费| 久久精品亚洲欧美日韩久久| 久久久噜噜噜久久|