這裏有很多例子,但我似乎無法弄清楚我的問題的解決方案。我有傳遞成員函數的指針
class FooSource{
...
void StartGetFoos(void (*callback)(vector<IFoo*>*, IAsyncResult));
...
}
當StartGetFoos()
被調用,它做得到FOOS,節約了回調的請求。當請求完成(大約需要30秒)時,保存的回調將被調用並返回結果。 我無法更改此方法的簽名。
和其他地方我有一個類
class FooUser {
...
void FooUser::MyCallback(vector<IFoo*>* foos, IAsyncResult result)
{
// marshall to UI thread and update UI
}
void init()
{
fooUser->StartGetFoos(??????);
// how do I pass my callback member function here?
}
}
相關:http://stackoverflow.com/questions/1738313/c-using-class-method-as-a-function-pointer-type –