How to detect that the phone (WP7) has stopped shaking

血红的双手。 提交于 2019-12-23 03:34:11

问题


I can get the phone to react to a shake, but what is the best way to tell that it has stopped shaking?


回答1:


This example worked for me.

At the very bottom of the page you'll see:

                if (!_shaking && CheckForShake(_lastReading, reading, ShakeThreshold) && _shakeCount >= 1)
                {
                    //We are shaking
                    _shaking = true;
                    _shakeCount = 0;
                    OnShakeDetected();
                }
                else if (CheckForShake(_lastReading, reading, ShakeThreshold))
                {
                    _shakeCount++;
                }
                else if (!CheckForShake(_lastReading, reading, 0.2))
                {
                    _shakeCount = 0;
                    _shaking = false;
                }



回答2:


Do like #Daniel Pereira said, but in the void ShakeDetected(object sender, EventArgs e) use a Dispatcher.BeginInvoke(() => youMethod()); and do what you pretend to do in youMethod(). I know this post is a little old but now other people can know how it resolve



来源:https://stackoverflow.com/questions/7357171/how-to-detect-that-the-phone-wp7-has-stopped-shaking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!