none
如何在C++中定义事件函数? RRS feed

  • 问题

  • 有代码

    MediaCapture^ captureMgr = ref new MediaCapture();
    IAsyncAction^ x = captureMgr->InitializeAsync();

    其中x有事件Completed。怎样才可以在C++中定义这个函数的事件?

    2014年5月6日 5:24

答案

  • 请尝试:

    x->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action)

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年5月7日 9:48
    版主

全部回复

  • 请尝试:

    x->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action)

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年5月7日 9:48
    版主
  • 如果我想在函数中增加几个参数怎么办?例如:

    类型为:st0,st1,st2

    形参为:xc0,xc1,xc2

    实参为:sc0,sc1,sc2

    2014年5月7日 13:15
  • 还有,编译器出现错误

    错误	1	error C2064: 项不会计算为接受 2 个参数的函数	microsoft visual studio 12.0\vc\include\vccorlib.h	875
    

    我的代码是:(因为你的代码少一个括号)

    	MediaCapture^ captureMgr = ref new MediaCapture();
    	IAsyncAction^ x = captureMgr->InitializeAsync();
    	int a = 0;
    	x->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action){
    		for (int i = 0; i < 10; i++){ ; }
    	});
    

    2014年5月7日 13:22
  • 我自己研究发现中括号里填写需要的变量名,不过谢谢回答。
    2014年5月10日 6:44