I\'ve been working on a Windows Phone 7 app for a few months now and have a collection of useful detection flags that are used to test for things like if the code is running
After reviewing the answers from Mike and Derek, I Decided to go with a simple timer to detect when the CameraCaptureTask
returns faster than expected. This is done by adding the following right before the call to start the capture task:
State["CameraCaptureStart"] = DateTime.Now;//Save start time to detect fast cancel from zune software
Then when the capture finishes you can detect if it returned too fast:
//Detect if task returned too fast
if (State.ContainsKey("CameraCaptureStart"))
{
DateTime dtStart = (DateTime)State["CameraCaptureStart"];
TimeSpan ts = DateTime.Now - dtStart;
if (ts < TimeSpan.FromSeconds(3))
{
MessageBox.Show("Error: Camera does not work while phone is connected to the Zune software.");
}
}
In my testing the fastest I could load the camera, take a picure, and push the accept button was around 5-6 seconds, where as the Zune software would automatic cancel and return in around 2.5 seconds.
This approach is simple and works well for my situation, however you should be aware that the error message will also be displayed if the user presses the back button before the 3 second timeout has elapsed.