您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 招标投标 > VB下多线程实现机制的比较
2282010,31(1)ComputerEngineeringandDesign0VBWindows2090VBVBVBVBVBVB311Win32APIWin32API[1-3]WindowsKernel32CreateThreadResume-ThreadTerminateThread[4]1.1VBWin32API2009-03-102009-05-15(1978)(1977)E-mailfengzhh503@126.comVB12(1.7100242.710072)VB4VBWin32APIActiveXDLLActiveXEXEThreadFactoryLibVBVB;API;;ActiveXDLL;ActiveXEXE;ThreadFactoryLibTP316A1000-7024(2010)01-0228-04ComparisonofseveralmultithreadtechniquesbasedonVBFENGZhao-hui1,FANRui-jun2(1.NorthwestInstituteofNuclearTechnology,Xian710024,China;2.NorthwesternPolytechnicalUniversity,Xian710072,China)AbstractTheVBprogramminglanguageisnon-threadedsafetyandnotsuitableformultithreadmode.Fromthetheory,methodsandeffectofapplicationareimplemented,fourkindsofmethodsarediscussedtoestablishmultithreadunderVBenvironment:Win32API,ActiveXDLL,ActiveXEXEandthreadfactorylib.Accordingtoapplicationrequirements,usingdifferentabove-mentionedmethods,VBmultithreadprogramisdeveloped,tofarthertakeadvantageofhighefficiency,rapidityandpowerinterfacedesignfunctionofVB.Keywordsmultithread;API;threadingmodel;ActiveXDLL;ActiveXEXE;threadfactorylibComputerEngineeringandDesign1DataPoolDataCollectDataDisplayVB2010,31(1)229(1)APIAPIPublicDeclareFunctionCreateThreadLibkernel32(ByVallpThreadAttributesAsAny,ByValdwStackSizeAsLong,ByVallpStartAddressAsLong,lpParameterAsAny,By-ValdwCreationFlagsAsLong,LpthreadIdAsLong)AsLongAPIPublicDeclareFunctionResumeThreadLibkernel32(ByValhThreadAsLong)AsLongAPIPublicDeclareFunctionTerminateThreadLibkernel32(ByValhThreadAsLong,ByValdwExitCodeAsLong)AsLongCreateThread3CreateThread(2)dataCollect()dataDisplay()PublicFunctiondataCollect()AsLong'EndFunctionPublicFunctiondataDisplay()AsLong'EndFunction(3)DataCollectThreadDataDisplayThreadPrivateSubForm_Load()DataCollectThread=CreateThread(0&,0&,AddressOfdata-Collect,0&,&HF,DataCollectThread)'IfDataCollectThread0ThenResumeThread(DataCollectThread)'EndIf'(4)DataCollectThreadData-DisplayThreadPrivateSubForm_Unload(CancelAsInteger)TerminateThread(DataCollectThread,0&)'TerminateThread(DataDisplayThread,0&)'1.2Win32APIVBIDEIDEEnd.exeVB[4]2VBActiveXDLLVBActiveXDLLSingleThreadedApartmentThreadedApartmentThreadedActiveXDLL2.1VBSingleThreadedActiveXDLL(1)ApartmentThreadedActiveXDLLDataCollectDataDisplayDataCollect.dllDataDisplay.dll(2)DataCollect.dllDataDis-play.dll(3)PrivateSubForm_Load()Setm_datacollect=CreateObject(DataCollect.cData-Collect)Setm_datadisplay=CreateObject(DataDisplay.cls-SWD)(4)m_datacollectm_datadisplayPrivateSubForm_Unload(CancelAsInteger)Setm_datacollect=NothingSetm_datadisplay=Nothing2.2ActiveXDLLDataCollectDataDisplayVBActiveXDLL(MainSTA)2ActiveXDLLAc-tiveXDLL3VBActiveXEXEVBActiveXEXEThreadperObjectActiveXEXEThreadPool2VBActiveXDLLVisualBasicMAINSTAPrimaryThreadObject1Object2Object32302010,31(1)ComputerEngineeringandDesignVBActiveXEXEVBThreadperObjectActiveXEXEActiveXEXE[5-6]3.1VBThreadperObjectActiveXEXE(1)ThreadperObjectActiveXEXEDataCollectDataDis-playDataCollect.exeDataDisplay.exe(2)DataCollect.exeDataDis-play.exe(3)2.2(4)(3)3.2ThreadperObjectActiveXEXE3()DataCollectDataDisplayCPU4ThreadFactoryLib2003HalfTimeVBThreadFactory[7]ThreadFactoryVB6DLLCOMActiveXDLL[7]ThreadFactoryC++MFCThreadFactoryAsyncObjectActiveXDLLWorkerThread2VBActiveXDLL3ThreadFactoryActiveXDLL3VBActiveXEXERPC4COMProxyStubProxyStubStubProxy4.1VBThreadFactory(1)DataCollectDataDisplayApartmentThreadedActiveXDLLDataCollect.dllDataDisplay.dl(2)DataCollect.dllDataDisplay.dllThreadFactoryLib.dll(3)ThreadFactoryAsyncObjectWorkerOb-ject2ActiveXDLLWorkerOb-jectPrivateSubForm_Load()Setdatacollect_oAsyncObject=NewAsyncObject'datacollect_oAsyncObject.CreateWorkerDataCollect.cData-Collect'DataCollectSetdatadisplay_oAsyncObject=NewAsyncObject'datadisplay_oAsyncObject.CreateWorkerDataDisplay.cData-Display'DataDisplay(4)3AsyncObjectAsyncCall.Begin_1ActiveXDLLActiveXDLL'Init()datacollect_oAsyncObject.ThreadPriority=THREAD_PRI-ORITY_TIME_CRITICALdatacollect_oAsyncObject.AsyncCall.Begin_Init'display()VisualBasicMAINSTAPrimaryThreadObject1AsyncObjectSTAWorkThreadObject1AsyncObjectSTAWorkThreadObject13ThreadFactoryLib4ThreadFactoryThreadBoundaryClient.exeProxyActiveXDLLObjectStubActiveXEXEServerProcessBoundaryClient.exeProxyRPCRuntimeTransportTransportRPCRuntimeStubAtiveXEXEObjectVB2010,31(1)231datadisplay_oAsyncObject.ThreadPriority='THREAD_PRIORITY_NORMALdatadisplay_oAsyncObject.AsyncCall.Begin_display(5)AsyncObjectAuto-CloseAsyncObjectPrivateSubForm_Unload(CancelAsInteger)datacollect_oAsyncObject.AutoCloseSetdatacollect_oAsyncObject=Nothing4.2ThreadFactory3515VB4ThreadFactoryAPIThreadFactoryCPUCPU6VBVBWin32APICreateThreadActiveXDLLVBActiveXDLLAc-tiveXEXEThreadFactoryVBVCVBVBVB[8]:[1],.VB[J].,2001,20(2):96-98.[2],.VB[J].,2001,27(8):157-159.[3],.VB[J].,2005(1):35-37.[4]VB[OL].[5],.VB[J].,2002,30(1):50-54.[6],.VB[J].,2006(9):40-41.[7]HalfTime®TechnologiesInc.ThreadfactoryTMv4.0help[R].2003.[8]VB.net[J].,2003,23(3):65-68.1VB4CPUAPIActiveXDLLActiveXEXEThreadFactorylib10%30%50%12%ActiveXLabWindows/CVIActive
本文标题:VB下多线程实现机制的比较
链接地址:https://www.777doc.com/doc-4371348 .html