.
D 2005-01-31T21:00:41
J assignee nijtmans
J cmimetype text/plain
J comment Here\sis\swhat\shappens:\n\n0.\sIn\sMacroMedia's\sDirector\sMX\s2004,\sI\slaunch\sa\sthread\s\n(via\s_beginthread,\scalled\sfrom\san\sxtra)\sthat\sstarts\sa\s\nTcl\sinterpreter\s(with\sTk,\sTclX\set\sal\sbuilt\sin).\s\n1.\sThe\sTask\sManager\sin\sWindows\sXP\sshows\sthat\sCPU\s\nconsumption\s\nrises\sto\s50-60%.\s\s(Note\sthat\sif\sI\suse\sthe\ssame\sTcl/Tk\s\nlibraries\soutside\sof\sthe\scontext\sof\sa\sDirector\sxtra,\sno\s\nsuch\spenalty\soccurs.)\s\n2.\sI\sthen\sload\sthe\sxtra\sand\sdebugged\sversion\sof\sTcl/Tk\s\n8.4.9\s\ninto\sVC++.\s\sI\sset\sbreakpoints\sat\sTk_MainLoop,\s\nTcl_DoOneEventÂ,\s\nand\sTcl_WaitForEvent.\s\n3.\sWhat\sI\sobserve\sis\sthat\safter\sinitialization,\sthe\sTcl\s\nthread\sessentially\sgoes\sinto\sa\spolling\smode\sin\swhich\s\nit\stries\sto\sprocess\sa\sWM_DEVICE_CHANGE\s(0x0219)\s\nmessage.\s\nThe\ssequence\sof\ssteps\sis\sthis\s(Note\sthat\sall\smessaging\s\nhere\sis\sdone\son\sthe\sthread;\sie,\sno\swindow\sis\sinvolved.):\s\n\n\n*\sTcl_DoOneEvent\sis\scalled.\s\n*\sTcl_WaitForEvent\sis\scalled.\s\n*\sPeekMessage\sis\scalled\sand\sfinds\sa\s\nWM_DEVICE_CHANGE\swith\s\nthe\swParam\sset\sto\sDBT_DEVNODES_CHANGED\s(0x0007).\s\n*\sGetMessage\sis\scalled\sand\sfinds\sthe\s\nWM_DEVICE_CHANGE\smsg.\s\n*\sTranslateMessage\sis\scalled\sand\sposts\sback\sthe\s\nWM_DEVICE_CHANGE\smsg\sto\sthe\smessaging\squeue\sfor\s\nthe\s\nthread.\s\n*\sDispatchMessage\sis\scalled\swith\sthe\s\nWM_DEVICE_CHANGE\smsg.\s\n\n\nAt\sthis\spoint,\sprogram\sexecution\sgoes\sback\sto\s\nTk_MainLoop,\sand\sthen\sTcl_DoOneEvent\sis\scalled\sand\s\nthe\swhole\ssequence\sof\ssteps\scontinues\sad\sinfinitum.\s\n\nNOTE:\sI\shave\sobserved\sthis\ssame\sbehavior\sfor\nan\sundefined\smessage\swith\sID\s0x0118.\s\sTo\scorrect\nthis\sinfinite\smessage-processing\sloop,\sI\sinserted\nthe\sfollowing\scode\sin\stcl8.4.9/win/tclWinNotify.c:\n\n\s\s\s\s\s\s\s\sresult\s=\sGetMessage(&msg,\sNULL,\s0,\s0);\n\s\s\s\s\s\s\s\swhile\s(msg.message\s==\sWM_DEVICECHANGE\s||\s\nmsg.message\s==\s0x0118)\s{\n\s\s\s\s\s\s\s\s\s\sresult\s=\sGetMessage(&msg,\sNULL,\s0,\s0);\n\s\s\s\s\s\s\s\s}\n\nThis\s"worked",\sin\sthe\ssense\sthat\ssaid\sinifinite\nprocessing\sloop\sno\slonger\soccurs.\n\nAlthough\sI'm\snot\ssure,\sI\sbelieve\sthat\slaunching\sa\sTcl\s\nthread\s\nin\sthis\smanner\striggers\sthe\sWM_DEVICE_CHANGE\s\nmessage,\sand\s\nthat\sthe\sTcl_DoOneEvent\sprocessing\slogic\sjust\sdoesn't\s\nhandle\s\nthis\scase\sgracefully.\s\sIE,\sthings\s"still\swork",\sbut\syou\s\nsacrifice\sa\shuge\samount\sof\sCPU\shorsepower\sin\sthe\s\nprocess.\s\n\nkodeCharlie
J foundin obsolete:\s8.4.9
J priority 5\sMedium
J resolution None
J status Open
J submitter kodecharlie
J subsystem 02.\sEvent\sLoops
J title Tk_MainLoop\sprocesses\sWM_DEVICE_CHANGE\sinfinitely\soften.
J type Bug
K 1113452fffffffffffffffffffffffffffffffff
U kodecharlie
Z 60e8b3f8ea0c00681dc3a848a1c8db43