많은 예제가 있지만 내 문제에 대한 해결책을 찾을 수없는 것 같습니다. 나는 StartGetFoos()
가 호출멤버 함수에 대한 포인터 전달
class FooSource{
...
void StartGetFoos(void (*callback)(vector<IFoo*>*, IAsyncResult));
...
}
,이 콜백을 절약하여 FOOS를 얻기 위해 수행 요청을해야합니다. 요청이 완료되면 (약 30 초 소요) 저장된 콜백이 결과와 함께 호출됩니다. 이 메서드의 서명을 변경할 수 없습니다.
는 다른 곳 난 당신이 멤버 함수를 사용할 수 있도록하는 this
포인터를받을 수 있도록 서명 void (*callback)(vector<IFoo*>*, IAsyncResult)
에 아무데도 없다 클래스를
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 –