简体   繁体   中英

Freeze while downloading with libcurl C/C++

I'm working on software which downloads a file and shows transfer speed via an SDL window. My problem is that when I launch a download, the window is immediately identified by windows as a crashed program. As soon as the download is completed, everything is okay. My program didn't crash and I think that it's because it can't respond when it's downloading. Any ideas how to solve that?

PS: example of code which 'crashes' when performed:

curl_easy_setopt(curl, CURLOPT_URL, valeurs->URL);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, FALSE);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, downloadData);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

为了防止这些冻结,您需要在主线程中放置一个事件管理器(SDL_PoolEvent + SDL_Delay以不过度使用CPU)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM