locked
Why my code caught an exception?

    Question

  • This is declaration:
    
    	public ref class Class_Base : public Windows::UI::Xaml::DependencyObject
    	{
    	protected private:
    		int gkk;
    	};
    	
    	public ref class Class_Derived sealed : public Class_Base
    	{
    	public:
    		Class_Derived() {}
    
    	private:
    		int a;
    		int b;
    		Platform::String^ str1;
    	};
    
    	public ref class Class_Derived2 : public Class_Base
    	{
    	public:
    		property int TypeA
    		{
    			int get() { return a; }
    		}
    
    	private:
    		int	a;
    	};
    
    	public ref class Class_3 sealed : public Class_Derived2
    	{
    	public:
    		Class_3() {}
    	};

    And next is calling code:

    MainPage::MainPage()
    {
    	InitializeComponent();
    
    	IAsyncOperation<bool>^ asyncOp = MyTestAsyncOp();
    	create_task(asyncOp);
    }
    
    IAsyncOperation<bool>^ MainPage::MyTestAsyncOp()
    {
    	return create_async([] () -> bool
    	{
    		Class_Tree^ pThree = ref new Class_Tree;			// OK
    		//Class_Base^ pBase = ref new Class_Base;			// Wrong
    		//Class_Derived^ pDerived = ref new Class_Derived;	// Wrong at here.
    		//Class_3^ pClass3 = ref new Class_3;				// Wrong
    
    		return true;
    	});
    }
    Why cann't I create new class, in an async thread???
    Wednesday, November 14, 2012 10:01 AM

Answers

All replies