async void myCallback_MessageReceived(object sender, MessageEventArgs e) { MyCallback myCallback = (MyCallback)sender; await lblMsg.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { lblMsg.Text += e.Message; lblMsg.Text += Environment.NewLine; }); }
protected override void OnNavigatedTo(NavigationEventArgs e) { NativeDll.DemoCx demoCx = new NativeDll.DemoCx(); MyCallback myCallback = new MyCallback(); myCallback.MessageReceived += myCallback_MessageReceived; demoCx.SetCallback(myCallback); // C# 调用 C++/CX lblMsg.Text += demoCx.HelloCx("cs to c++/cx"); lblMsg.Text += Environment.NewLine; // C# 通过 C++/CX 调用 C/C++ lblMsg.Text += demoCx.HelloCpp("cs to c++/cx to c/c++"); lblMsg.Text += Environment.NewLine; }