wininet异步操作类学习总结[2012/07/11 补充]

来源:互联网 发布:hishop云商城3.0源码 编辑:程序博客网 时间:2024/06/16 03:01

网上查了很多资料,也看了很多教程,自己写了一个wininet异步操作类...

多线程使用的还可以,也解决了请求拥堵问题。

 

参照文章:

http://topic.csdn.net/u/20110126/17/40811C5F-A561-47F9-AEB0-43C9A893F35B.html

http://blog.csdn.net/cpq37/archive/2010/11/18/6019525.aspx

 

 

WininetAsync.h

 

 

WininetAsync.cpp

 

 

封装到自定义线程类中的成员变量,不使用使用局部对象,防止局部对象失效后依然传递进回调函数导致野指针

 

 

调用

 

 

 

 


补充 - 2012/07/11:

异步调用,如何正常终结回调函数

InternetCloseHandle function

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384350(v=vs.85).aspx

It is safe to call InternetCloseHandle in a callback for the handle being closed. If there is a status callback registered for the handle being closed, and the handle was created with a non-NULL context value, an INTERNET_STATUS_HANDLE_CLOSING callback will be made. This indication will be the last callback made from a handle and indicates that the handle is being destroyed.

 以上代码有2个异步句柄,确保 INTERNET_STATUS_HANDLE_CLOSING 被调用2次后,析构该对象

原创粉丝点击