从异步方法调用事件时出现问题 [英] Problem in calling a event from async method

查看:139
本文介绍了从异步方法调用事件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在类中定义了一个委托和事件,如下所示:

I have defined a delegate and event in the class like this:

public delegate void ResponseHandler();

event ResponseHandler^ responseEvent;

然后从类方法中,我将事件触发为:

and then from a class method, I fired event as:

someAsyncFunction().then([this]()
 {
		
responseEvent();
		
});

从另一个地方,我订阅了这个事件:

From another place, I subscribed to the event as:

mWebServiceComponent->responseEvent += ref new WebServiceComponent::ResponseHandler([this]() {  });

但是,这不起作用,应用程序在调用responseEvent时引发异常。例外情况是:

But, this is not working and application raises an exception while calling the responseEvent. The exception is:

" WWAHost.exe中0x50CB9AD1(msvcr110d.dll)处的未处理异常:将无效参数传递给认为无效参数致命的函数。



如果有这个例外的处理程序,程序可以安全地继续。"

"Unhandled exception at 0x50CB9AD1 (msvcr110d.dll) in WWAHost.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.

If there is a handler for this exception, the program may be safely continued."

这真让我疯狂。这段代码有什么问题?请一些人帮忙!!

This is really driving me crazy. What is wrong with this code? Could some please help!!

提前致谢。




推荐答案

有人请回复!我被困了!!!
Someone please reply! I am stuck!!!


这篇关于从异步方法调用事件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆