如何在onSensorChanged(SensorEvent e)方法中延迟我的SensorListener?

时间:2019-04-02 09:03:43

标签: c# xamarin.android delay android-sensors

我确实收到错误消息,指出我的代码增加了代码检查能力,因此我添加了一个延迟(Thread.Sleep(1000)),还尝试了OnPause来注销侦听器。

public void OnSensorChanged(SensorEvent e)
        {
            lock (_syncLock)
            {
                newValue = e.Values.Average();
                int noteInt1 = Convert.ToInt32(previousValue);
                int noteInt2 = Convert.ToInt32(newValue);

                try
                {
                    OnPause();
                    Thread.Sleep(1000);
                    if (newValue != previousValue)
                    {
                        _sensorTextView2.Text = string.Format("Note: {0}", newValue);
                        eventnumbers.Add(newValue);
                    }

                    OnResume();
                }
                catch (ArgumentNullException)
                {
                    Console.WriteLine(e);
                }

            }

            _sensorTextView.Text = string.Format("x={0:f}, y={1:f}, z={2:f}", e.Values[0], e.Values[1], e.Values[2]);

        }

这是我的输出

04-02 08:28:11.062 D / Mono(32147):DllImport搜索于'__Internal'('(null)')。 04-02 08:28:11.062 D / Mono(32147):搜索'java_interop_jnienv_new_local_ref'。 04-02 08:28:11.062 D / Mono(32147):探测'java_interop_jnienv_new_local_ref'。 04-02 08:28:11.062 D / Mono(32147):找到为'java_interop_jnienv_new_local_ref'。 04-02 08:28:11.187 I / Choreographer(32147):跳过了98帧!该应用程序可能在其主线程上做太多工作。 04-02 08:28:11.208 D / EGL_emulation(32147):eglMakeCurrent:0xa1f050c0:ver 3 0(tinfo 0xa1f03310) 04-02 08:28:12.519 I / Choreographer(32147):跳过了79帧! 该应用程序可能在其主线程上做过多的工作。 04-02 08:28:47.401 W / zygote(32147):dex base.apk的校验和不匹配

04-02 08:28:47.401 W/zygote  (32147): Checksum mismatch for dex base.apk
04-02 08:28:53.370 I/zygote  (32147): Do partial code cache collection, code=24KB, data=28KB
04-02 08:28:53.372 I/zygote  (32147): After code cache collection, code=24KB, data=28KB
04-02 08:28:53.372 I/zygote  (32147): Increasing code cache capacity to 128KB
04-02 08:29:27.411 W/zygote  (32147): Checksum mismatch for dex base.apk
04-02 08:29:27.411 W/zygote  (32147): Checksum mismatch for dex base.apk
04-02 08:29:35.546 I/zygote  (32147): Do partial code cache collection, code=59KB, data=58KB
04-02 08:29:35.546 I/zygote  (32147): After code cache collection, code=59KB, data=58KB
04-02 08:29:35.546 I/zygote  (32147): Increasing code cache capacity to 256KB

0 个答案:

没有答案