在下面的代码中,main()函数调用request()函数,它调用了函数mm_th_done_cb()的th_request_async()函数。等待回调完成的最佳方式
只有在执行了mm_th_done_cb()之后,什么才是在main中继续进行的最佳和有效的方式。
虚设码
int mm_th_done_cb(int error_code, th_result_s* th_result, void* user_data)
{
return 0;
}
void request()
{
th_request_s MyItemInfo;
strncpy(MyItemInfo.origin_path, szUrl, 1024+1);
MyItemInfo.orientation = 0;
MyItemInfo.func = mm_th_done_cb;
MyItemInfo.used_cache = 1;
th_request_async(MyItemInfo);
}
int main()
{
request();
// Here I need to do something only after mm_th_done_cb() has been excuted.
}
将呼叫,使其成为自由语句之前NULL。 –