初始化后,本机组件函数自指针(this->)为null。 [英] Native component function self pointer ( this-> ) is null all though after initialization.

查看:55
本文介绍了初始化后,本机组件函数自指针(this->)为null。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Native Camere API,并且自己实现previewSink接口,以便在预览框架可用时进行一些处理。为了能够将此传递给托管方, 

I am using the Native Camere API , and implementing the previewSink interface myself to do some processing whenever a preview frame is available. To be able to pass this to managed side, 

- 我将该变量声明为previewSink类的成员。

- I declare the variable as a member of previewSink class.

- 我声明了一个WinRT组件中的公共属性,其get函数调用previewSink类的getter。

- I declare a public property in WinRT component whose get function calls the getter of previewSink class.

在托管方面,我所做的最小样本是:

In the managed side, a minimal sample of what i do is:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            nativeCapture = new NativeCapture();
            while (nativeCapture.Done == false) ;
            viewFinderBrush.SetSource(nativeCapture.NPhotoCaptureDevice);

            var a = nativeCapture.DetectedRectangleCoordinates; // the problem occurs here

            base.OnNavigatedTo(e);
        }

在我尝试访问所需值的行中,尝试读取或写入受保护内存的异常是抛出。奇怪的是,当我在这里设置断点并通过步进执行此行时,不会抛出任何异常。 

At the line, where I try to access the desired value an exception of Attempted to read or write protected memory is thrown. Oddly, when I set a breakpoint here and execute this line by stepping, no exception is thrown. 

当我在本机端设置断点时,在DetectedRectangleCoordinates属性的getter函数处,我意识到"这个"指针为空,在异常之前。但我无法理解为什么这个指针为空。 

When I set a breakpoint on native side, at the getter function of the DetectedRectangleCoordinates property , I realized that "this" pointer is null, threfore the exception. But I could not understand why this pointer is null. 

所有相同的,如果nativeCapture尚未正确初始化,我想我不应该将它分配给源视频画笔(我可以)和停止并踩到断点线是可以的。

All the same, if the nativeCapture has not been initialized properly, I suppose I should not be able to assign it to the source of video brush ( which I could) and stopping and stepping at breakpoint line is ok.

我真的很感激任何帮助,因为我被困在这里这么久。

I really appreciate any help, because I am stuck here for so long.

谢谢,

Bahtiyar

推荐答案

我的猜测是这个超紧循环不允许初始化:

My guess is that this super tight loop does not allow initialization:

  while nativeCapture 完成
== false
;

        ;   

 while (nativeCapture.Done == false) ;
         

改为使用异步电话。


这篇关于初始化后,本机组件函数自指针(this->)为null。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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