locked
Problem in calling a event from async method

    Question

  • 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]() {  });

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

    "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!!

    Thanks in advance.


    Friday, August 31, 2012 6:47 PM

All replies

  • Someone please reply! I am stuck!!!
    Saturday, September 1, 2012 7:37 PM
  • You should turn on First chance exceptions (Debug > Exceptions...) in the debugger to see whether your code is throwing any other exceptions before the one you mentioned. Chances are that a C++ exception is trying to go over the ABI boundary and the process is terminated because of that. Only Platform::Exception exceptions are allowed to pass the ABI boundary.

    Hope this helps,
    Marian Luparu
    Visual C++

    Sunday, September 2, 2012 11:17 PM