I have written a C# application that monitors a device attached to an ARM tablet running Windows 8. The application needs to detect when the tablet is resuming from sleep, so that it can send a command to the attached device.
I have tried monitoring the Microsoft.Win32.SystemEvents.PowerModeChanged event, as per this question.
I have tried watching for WM_POWERBROADCAST messages, as per this question.
In both cases the application works fine on my Windows 7 desktop development PC. However, neither approach works when I run the application on my Windows 8 ARM tablet.
Do I need to watch for a different message in this case? Is there something else I could try to work around this problem?
UPDATE: I have since found that when I plug or unplug mains power I do actually get a WM_POWERBROADCAST message (power status change). I also get a SystemEvents.PowerModeChanged event. However I am still not receiving any suspend or resume power messages when going through a suspend/resume cycle.
UPDATE #2: I have since found a workaround for my particular situation that does not rely on power messages. But thanks to those who took the time to answer/comment.
Related
In my app I have UP and DOWN channels which continuously listen for Audio stream.
I want to know that In windows is there any event which will tell me that machine is now going to sleep state (not sign-out because machine will go to sleep after sign-out based on the user settings) so that i can suspend the channels and once machine wake-up(Not sign-in because machine wake up before the sign-in even) then i can resume it again.
Something similar to Cortana
Thanks in advance.
There's no 'sleep' relevant APIs for you to detect if the windows will go to sleep in UWP.
If you check the Windows 10 universal Windows platform (UWP) app lifecycle, you will find that Suspending and Resuming are the right events to listen to.
We're writing a cross-platform C# "Xamarin" application; right now we're just targeting the iPad. The application has two features relevant to this question:
The app requires that the user authenticate to the app (in addition to logging onto the iPad)
The app connects to a remote device over Bluetooth
So the question becomes, what happens when the user switches to another app, which results in our app's OnSleep() being called. In OnSleep() we could immediately disconnect Bluetooth and log out the user, but that seems like poor usability, especially if they are just quickly checking some alarm that triggered or an instant message that came in.
For the sake of usability, we're thinking to have a 1-minute timeout; if the user does in fact pop out and quickly pop back into the app, we'd like things to simply continue on without any loss of communication or re-authentication.
If, in OnSleep(), I set up a timer using Xamarin.Forms.Device.StartTimer(), that timer does not fire while the app is "asleep".
What does it take to have a small background task/thread/process execute, even while the app is asleep? Something that simply waits 1 minute, and then shuts down the Bluetooth communication and sets a flag indicating re-authentication is needed?
I'm working on a Windows Universal App that communicates with BluetoothLE heart rate monitors. As of yesterday (related to a windows update, I'm thinking), things appear to be suddenly broken.
Specifically:
When I first pair a HRM device to my computer (in windows settings, not through their API), my app sees the device just fine, and can subscribe to notifications from the GATT Heart Rate Service (through a method close to the code here, in the C# sample.)
In all subsequent connection attempts, the app will detect the device normally, and indicate that it is paired to windows, but the HRM in question has a Device.ConnectionStatus of BluetoothConnectionStatus.Disconnected, and never reports hear rate updates.
If you run the MSDN sample above, you'll see the same thing, even though it's a Windows 8/8.1 sample.
This leaves me in a really sticky spot - I need to be able to communicate with these devices, but as of right now, it appears that I can only do so consistently unpairing the device from windows, and repairing it. That is obviously not acceptable.
I've found a few articles that seem to be tangentially related, but none seem to have found a solution. Help!
I have a Windows Store App (Metro) that uses toast notifications. The notifications work beautifully when remote debugging on my WinRT device (Surface 2). However, when running on my desktop in Local Machine or Simulator mode, they are really erratic. Sometimes showing up several minutes later and occasionally not at all. Does anyone know how to fix this?
Can we run some task on specific time in background if my application is running or on dormant state. Is this possible in windows phone 7.5 Mango. If Its not possible then any work around with the help of push notifications.
If you are not the currently active application in Windows Phone your application is being tombstoned, which means that some of your state is saved and your application is halted (e.g. there is no code running for your application anymore).
Therefor you can not create code that allows your application to do anything at a specific time, without using push notification.
Even with push notification your options are very limited. It realy depends on what you want to happen when a notification arives.