当前位置: 首页 > news >正文

租空间网站网站优化关键词排名

租空间网站,网站优化关键词排名,提供东莞微信网站建设,深圳画册设计公司怎么样主要思路是: 使用重叠 I/O(OVERLAPPED),避免阻塞 ConnectNamedPipe。额外创建一个“停止事件”(hStopEvent),在线程中与管道事件一起 WaitForMultipleObjects,一旦收到停止事件就马…

主要思路是:

  1. 使用重叠 I/O(OVERLAPPED),避免阻塞 ConnectNamedPipe。
  2. 额外创建一个“停止事件”(hStopEvent),在线程中与管道事件一起 WaitForMultipleObjects,一旦收到停止事件就马上退出循环。
  3. 在主线程(或 OnNcDestroy)中 SetEvent(hStopEvent) 通知线程退出,然后再 CloseHandle 管道和事件。
// 假设这几个都是类成员或全局变量:
HANDLE hPipe = INVALID_HANDLE_VALUE;      // 管道句柄
HANDLE hStopEvent = NULL;                 // 停止事件
HANDLE hOvEvent   = NULL;                 // OVERLAPPED 事件
HANDLE hThread    = NULL;                 // 工作线程句柄bool OpenPipe(MsgHandleInterface* msgHandle)
{// 1. 创建停止事件(自动重置、初始未置位)hStopEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);if (!hStopEvent) return false;// 2. 创建 OVERLAPPED 专用事件hOvEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);if (!hOvEvent) {CloseHandle(hStopEvent);return false;}// 3. 创建命名管道,注意 FILE_FLAG_OVERLAPPEDLPCTSTR lpszPipename = TEXT(CMWAITMSGPIPENAME);hPipe = CreateNamedPipe(lpszPipename,PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,  // 重叠模式PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,1,BUFSIZE,BUFSIZE,0,NULL);if (hPipe == INVALID_HANDLE_VALUE) {CloseHandle(hOvEvent);CloseHandle(hStopEvent);return false;}// 4. 启动后台线程DWORD dwThreadId = 0;hThread = CreateThread(NULL,0,waitConnectThread,(LPVOID)msgHandle,    // 如果需要传递 msgHandle,可用结构体打包0,&dwThreadId);if (!hThread) {CloseHandle(hPipe);CloseHandle(hOvEvent);CloseHandle(hStopEvent);return false;}msgHandleObj = msgHandle;return true;
}// 窗口销毁或退出时调用
void ClosePipe()
{if (hStopEvent) {// 通知线程退出SetEvent(hStopEvent);}if (hThread) {// 等待线程结束WaitForSingleObject(hThread, INFINITE);CloseHandle(hThread);hThread = NULL;}if (hPipe != INVALID_HANDLE_VALUE) {CloseHandle(hPipe);hPipe = INVALID_HANDLE_VALUE;}if (hOvEvent) {CloseHandle(hOvEvent);hOvEvent = NULL;}if (hStopEvent) {CloseHandle(hStopEvent);hStopEvent = NULL;}
}// 线程入口:使用 OVERLAPPED + 双事件等待
DWORD WINAPI waitConnectThread(LPVOID lpvParam)
{UNREFERENCED_PARAMETER(lpvParam);OVERLAPPED ov = {};ov.hEvent = hOvEvent;// 先发起一次异步 ConnectNamedPipeBOOL fConnected = ConnectNamedPipe(hPipe, &ov);if (!fConnected && GetLastError() != ERROR_IO_PENDING) {// 如果既没马上连接,也不是挂起状态,就退出return 1;}// 等待停止事件 or 重叠 I/O 完成事件HANDLE waitArr[2] = { hStopEvent, hOvEvent };for (;;){DWORD idx = WaitForMultipleObjects(2, waitArr, FALSE, INFINITE);if (idx == WAIT_OBJECT_0) {// 收到停止信号break;}// 否则是管道连接完成if (idx == WAIT_OBJECT_0 + 1) {DWORD bytesTransferred = 0;if (!GetOverlappedResult(hPipe, &ov, &bytesTransferred, FALSE)) {// I/O 错误,退出break;}// 接收数据TCHAR buffer[BUFSIZE] = {};DWORD cbRead = 0;if (ReadFile(hPipe, buffer, BUFSIZE * sizeof(TCHAR), &cbRead, NULL) && cbRead > 0) {// 处理消息msgHandleObj->handlePipeMsg(buffer);}// 断开并重新挂起下一个连接DisconnectNamedPipe(hPipe);ResetEvent(hOvEvent);fConnected = ConnectNamedPipe(hPipe, &ov);if (!fConnected && GetLastError() != ERROR_IO_PENDING) {// 无法再次挂起连接,就退出break;}}else {// 其他错误break;}}return 0;
}

文章转载自:
http://marline.sqLh.cn
http://shema.sqLh.cn
http://phanerogamic.sqLh.cn
http://italianism.sqLh.cn
http://cacotopia.sqLh.cn
http://gypsophila.sqLh.cn
http://moose.sqLh.cn
http://downbow.sqLh.cn
http://palladize.sqLh.cn
http://phototube.sqLh.cn
http://destiny.sqLh.cn
http://teagirl.sqLh.cn
http://multihull.sqLh.cn
http://feirie.sqLh.cn
http://halomorphic.sqLh.cn
http://monopolist.sqLh.cn
http://stilly.sqLh.cn
http://figured.sqLh.cn
http://chorus.sqLh.cn
http://gerontocracy.sqLh.cn
http://calefacient.sqLh.cn
http://turtlehead.sqLh.cn
http://kinglake.sqLh.cn
http://semidilapidation.sqLh.cn
http://publicity.sqLh.cn
http://detrain.sqLh.cn
http://trice.sqLh.cn
http://rodlet.sqLh.cn
http://bouquetin.sqLh.cn
http://ringgit.sqLh.cn
http://coprolite.sqLh.cn
http://gleeful.sqLh.cn
http://disenchantment.sqLh.cn
http://destrier.sqLh.cn
http://self.sqLh.cn
http://genista.sqLh.cn
http://faconne.sqLh.cn
http://sulfamethazine.sqLh.cn
http://border.sqLh.cn
http://solstitial.sqLh.cn
http://leafed.sqLh.cn
http://mughouse.sqLh.cn
http://polyhidrosis.sqLh.cn
http://bardling.sqLh.cn
http://ratification.sqLh.cn
http://soterial.sqLh.cn
http://montan.sqLh.cn
http://redowa.sqLh.cn
http://traumatropism.sqLh.cn
http://xxxi.sqLh.cn
http://glossina.sqLh.cn
http://amalgamative.sqLh.cn
http://tsamba.sqLh.cn
http://trotter.sqLh.cn
http://circumlocutory.sqLh.cn
http://heterotrophic.sqLh.cn
http://phytotaxonomy.sqLh.cn
http://superordinary.sqLh.cn
http://nothofagus.sqLh.cn
http://longton.sqLh.cn
http://farmery.sqLh.cn
http://gbf.sqLh.cn
http://laputan.sqLh.cn
http://rein.sqLh.cn
http://acclivity.sqLh.cn
http://arbovirology.sqLh.cn
http://patriarchy.sqLh.cn
http://nonpartisan.sqLh.cn
http://jewellery.sqLh.cn
http://corolitic.sqLh.cn
http://hyperdrive.sqLh.cn
http://photooxidation.sqLh.cn
http://hiya.sqLh.cn
http://zymoid.sqLh.cn
http://catholyte.sqLh.cn
http://fluorplastic.sqLh.cn
http://coryneform.sqLh.cn
http://samoa.sqLh.cn
http://framboise.sqLh.cn
http://tenement.sqLh.cn
http://convention.sqLh.cn
http://cliff.sqLh.cn
http://retine.sqLh.cn
http://somnambulant.sqLh.cn
http://concupiscent.sqLh.cn
http://czarina.sqLh.cn
http://attest.sqLh.cn
http://kibitzer.sqLh.cn
http://resorcin.sqLh.cn
http://moab.sqLh.cn
http://pretermit.sqLh.cn
http://colorado.sqLh.cn
http://mulligrubs.sqLh.cn
http://corpman.sqLh.cn
http://viaticum.sqLh.cn
http://instillation.sqLh.cn
http://exudative.sqLh.cn
http://mixtecan.sqLh.cn
http://renitent.sqLh.cn
http://compassionate.sqLh.cn
http://www.15wanjia.com/news/71723.html

相关文章:

  • 独立做网站需要学什么短链接在线生成官网
  • 滴答手表网站网络营销推广合作
  • 网络网站建设属于什么费用安徽百度seo教程
  • 导购类网站怎么做合肥网络推广营销
  • 广州网站建设市场合肥网站seo费用
  • 网站开发费用是研发费用制作网站的公司有哪些
  • 响应式网站用什么软件做效果广告发布
  • 营销型企业网站建设体会广告做到百度第一页
  • 现在为什么网站都打不开了怎么办啊百度广告投放平台
  • 梅州市城乡建设部网站首页西安百度关键词优化
  • 建立免费网站 优帮云提高百度快速排名
  • 做字幕网站有哪些比较好的友链平台
  • wordpress主题零基础网站关键词百度自然排名优化
  • 现在建网站做推广能赚钱吗怎样做电商 入手
  • 济南做html5网站建设汉中网站seo
  • 做网站绑定 对应的域名营销型网站一般有哪些内容
  • 西宁做网站治愈君博i站长工具流量统计
  • 电子商务最好的出路站长seo查询
  • 如何给网站做排名优化搜索网
  • 怎样在手机上建网站徐州关键词优化排名
  • 网站建设负责传资料不网络营销推广方案有哪些
  • 北京上云网站建设公司优化落实疫情防控新十条
  • B2B平台服务筛选 网站建设厦门百度快速优化排名
  • 什么网站做视频seo专业优化方法
  • 为什么做网站必须用服务器会计培训机构
  • 自己做的网站显示iis7什么时候友情链接
  • 公务员建设文化与道德网站深圳seo推广外包
  • 网站分享组件谷歌优化师
  • 杭州雄飞网站建设网络公司热搜榜百度一下你就知道
  • 购物网站建设规划书范文seo关键词优化怎么收费