vc多少钱一瓶合适(vc多线程)
- 编辑:admin - 点击数:712vc多少钱一瓶合适(vc多线程)
1、在VC中可以调用MFC函数AfxBeginThread,创建线程。

2、线程做什么,怎么做就得看你自己的设计了。
3、贴一段MSDN里的代码:VisualC++CopyCodeclassCSockThread:publicCWinThread{public:SOCKETm_hConnected;protected:CChatSocketm_sConnected;//remainderofclassdeclarationomitted.VisualC++CopyCodeBOOLCSockThread::InitInstance(){//Attachthesocketobjecttothesockethandle//inthecontextofthisthread.m_(m_hConnected);m_hConnected=NULL;returnTRUE;}VisualC++CopyCode//Thislisteningsockethasbeenconstructed//intheprimaryCListeningSocket::OnAccept(intnErrorCode){UNREFERENCED_PARAMETER(nErrorCode);//ThisCSocketobjectisusedjusttemporarily//toaccepttheincomingconnection.CSocketsConnected;Accept(sConnected);//Starttheotherthread.CSockThread*pSockThread=(CSockThread*)AfxBeginThread(RUNTIME_CLASS(CSockThread),THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);if(NULL!=pSockThread){//Detachthenewlyacceptedsocketandsave//theSOCKEThandleinournewthreadobject.//Afterdetachingit,itshouldnolongerbe//usedinthecontextofthisthread.pSockThread->m_hConnected=();pSockThread->ResumeThread();}}。
以上就是【vc多少钱一瓶合适,vc多线程】相关内容。