locked
Lambda function for data changed?

    Question

  • I am trying to have a Lambda function called on a data changed event, and I have made numerous syntax changes to no avail.  Here is what I have, can someone point me in the right direction?  The example below is in a simple C function not a class method.

    auto prefsDelegate = [](Windows::Storage::ApplicationData^ appData, Object^ o)
    {
    	printf("prefs changed");
    };
    	
    ApplicationData::Current->DataChanged += ref new TypedEventHandler<ApplicationData^, Object^>( settings, prefsDelegate );

    Regards, Guy

    Wednesday, April 11, 2012 5:25 PM

Answers

  • Hello,

    You can add the Lambda function name directly, no need the class name. Please follow these codes

    ApplicationData::Current->DataChanged += ref new TypedEventHandler<ApplicationData^, Object^>( prefsDelegate );


    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by gnichola Thursday, April 12, 2012 4:02 PM
    Thursday, April 12, 2012 6:23 AM