fix merge conflict
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/90ef274e Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/90ef274e Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/90ef274e Branch: refs/heads/master Commit: 90ef274ea8cae2a5639d148b769f7718f33b7134 Parents: 5b0338f e353074 Author: Jesse MacFadyen <[email protected]> Authored: Fri Oct 23 17:58:30 2015 -0700 Committer: Jesse MacFadyen <[email protected]> Committed: Fri Oct 23 17:58:30 2015 -0700 ---------------------------------------------------------------------- src/wp/Accelerometer.cs | 5 +++++ 1 file changed, 5 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/90ef274e/src/wp/Accelerometer.cs ---------------------------------------------------------------------- diff --cc src/wp/Accelerometer.cs index 33c5434,005e4c3..d7a95b5 --- a/src/wp/Accelerometer.cs +++ b/src/wp/Accelerometer.cs @@@ -76,24 -118,38 +76,29 @@@ namespace WPCordovaClassLib.Cordova.Com { return; } + try { - lock (accelerometer) - { - accelerometer.CurrentValueChanged += accelerometer_CurrentValueChanged; - accelerometer.Start(); - this.SetStatus(Starting); - } - - long timeout = 2000; - while ((currentStatus == Starting) && (timeout > 0)) - { - timeout = timeout - 100; - Thread.Sleep(100); - } - - if (currentStatus != Running) - { - this.SetStatus(ErrorFailedToStart); - DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart)); - return; - } + // we use 20ms as a minimum allowed update interval + int minReportInterval = Math.Max((int)accelerometer.MinimumReportInterval, 20); + + updateTimer = new Timer(ReportAccelerationValue, null, 0, minReportInterval); + this.SetStatus(Running); + + PluginResult result = new PluginResult(PluginResult.Status.OK, GetCurrentAccelerationFormatted()); + result.KeepCallback = true; + DispatchCommandResult(result, watchCallbackId); } - catch (Exception) + catch (Exception ex) { this.SetStatus(ErrorFailedToStart); - DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart)); + DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ErrorFailedToStart), watchCallbackId); + return; } + PluginResult result = new PluginResult(PluginResult.Status.OK); + result.KeepCallback = true; - DispatchCommandResult(result); ++ DispatchCommandResult(result,watchCallbackId); ++ } public void stop(string options) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
