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 in the emulator, on a background/foreground thread, or at design time. (see full list here)
I now want to add a new flag that will check if the phone is connected to a desktop using a USB cable to prevent issues that users are reporting. There are certain operations that are blocked while the phone is connected to the Zune software, for example you cannot use the camera (it will just open and then immediately close with e.TaskResult == Microsoft.Phone.Tasks.TaskResult.Cancel). This causes my app to think that the user canceled the photo, which the user miss-interprets as the app not working correctly.
I'd like to detect when the phone is connected to the Zune software and provide a message saying the camera will not work until they disconnect it. Is there any way to do this?
Gabor Dolhai has a full blog post on Zune Detection and Network Awareness, which uses a combiantion of NetworkInterfaceType detection and the NetworkAddressChangeed event.