How to stop a PDA sleeping - c#

I have an application for PDAs with a long running process, and I'm getting the problem that the PDA is going to sleep before the process has completed.
I haven't got any control over the power settings on the PDA, does anyone know a good way for my application to stop the PDA from going to sleep?
Many thanks

Have a look at:
http://www.pinvoke.net/default.aspx/coredll.SystemIdleTimerReset

You need to make a function that calls SystemIdleTimerReset, SHIdleTimerReset and simulates a key touch. Then you need to call it on a regular basis from within your application.
For an example in C++, look here:
Disable sleep mode in Windows Mobile 6

Related

asp.net Website Serverside threads

I am creating a little Website which is basically a leaderboard from a specific game.
Im using C#6 - 4.6.
I am using a Webhosting by 1and1.
My question/problem:
The leaderboard has to update itself every 10 minutes. I am using an API to get the newest informations and then save it into a mysql db.
I cannot use cronjobs(using Windows hosting) and i cannot create scheduled tasks (Only webhosting and not a server...).
I was talking to support, but they could not help me because of lagg of knowledge in c# and win hosting.
So i tested something in my Visual studio: I created a seperate Thread which does the update, wait for X minutes and then does it again (infinit, until i stop it).
Works like a charm on my pc, but when i publish it to the server, the thread starts executing and actually writes that into the log, but after around 10 seconds there is no more respond from the thread.
Everything from that thread is running serverside.
Can someone explain this to me or has a better idea on how to solve it?
If you need any code snippets, please let me know!
Thanks in advance,
Markus

Xamarin iOS - SignalR stops receiving messages in background mode

Currently i am developing an app which needs to be capable of receiving and interacting based on realtime event notifications from all platforms. We are using SignalR to achieve so. I am using Xamarin.Forms as this is a shared project.
Right now everything is working fine especially android is perfect. No matter application is in background or foreground its receiving messages from SignalR and playing sound and vibrates as expected. In iOS 10.3 simulator also its working as expected. Untill yesterday when i realized in real device when application goes in background mode it pauses everything and when its back in foreground it resumes as its supposed to be doing and as if the notification was sent just now. So i did some research and thought i would perform a long running task (in my case a forever loop with a 10seconds interval) in the background thread and in that way i was able to receive signalr messages (which i can see on the debugger) and vibration was playing while being in background. But after a certain time i am guessing within 10 mins iOS is clearing up its memory and when i open the app it seems reloaded because it shows the login screen instead of where i left the app.
Now question is:
1. How can i keep receiving SignalR events while being in background?
2. How can i stop iOS to reload my app due to being in background for a long time?
3. The app has to be Appstore publishable as in appstore must not reject it due to some dodgy works being done in the background like playing silent audio forever or using VoIP for background since this is not a VoIP app.
4. Also soon i am gonna be implementing location update in background mode so is this gonna keep the whole app alive in background? And behave like i am expecting?
As i am currently travelling i can not provide any code snippet but any questions please feel free to ask.
Thanks for your help and reading this boring article.
Just in case if someone is facing similar issue.
Apple doesnt allow to execute your app unless it falls in certain category Look at table 3-1. Fortunately, I had a valid reason to use continuous location update in foreground and background therefore as soon as I implemented location update event all my problems were solved immediately.
How to implement location update? Location DependencyService example for Xamarin.Forms
Hope that will help.

Programmatically set wake on time

We are creating a display system which we will be running on top of Windows 7 embedded.
The computers will not have keyboard or mouse, thus will have no direct user interaction.
Since these computers will only be used during certain times we would like to define schedules for them and make them power off (including their screens), and automatically power on again at specific times.
For this, we need to be able to set the bios WakeOnRTC timer from code. It is not sufficient to wake from hibernate or sleep, as referred to at Schedule machine to wake up.
I know from others that MythBuntu can do this, but that is Linux-based.
I've also heard this is easier to achieve with UEFI-bioses that are emerging.
At this point we are open to select any bios if anyone has a solution.
I'm not going to put too much because this question has already been answered, see the following links.
C#: How to wake up system which has been shutdown?
http://www.codeproject.com/Articles/49798/Wake-the-PC-from-standby-or-hibernation
In short the solution revolves around the following two Win32 API functions:
CreateWaitableTimer
SetWaitableTimer

How to prevent terminal (Windows-CE) from shut-down after 5 minutes

How to prevent terminal (Windows-CE) from shut-down after 5 minutes
the terminal is Motorola MC3190 (Windows-CE) and if i dont touch the screen for 5 minutes
the terminal shut-down. how to prevent this ?
i need the solution in C# code.
thanks in advance
I initially voted to close, but have been thinking more about this, and I think the question you've asked may have been missing an important piece of information.
I think what you need to look at are the Windows CE Power Management functions, specifically SetPowerRequirement. This allows you to indicate that your application is using some device within the system. If not, it's unclear why your application, absent some device interactions, wants to prevent power management from doing its job.
No code needed for this. Go to Start->Settings->Power and uncheck the box next to "Turn off screen if device not used for".
If you tried to do this programmatically, you would be draining the battery power faster than the user intends. That will probably irritate your user.
If your heart is set on doing this, then you can modify the value in [HKLM]\System\CurrentControlSet\Control\Power\Timeouts
I also gave this answer on the MSDN forums
-PaulH
I dont know Windows-CE and i Dont know C#, but I found you an answer on google. Here you go. And now I want to try programing something for some station. Would be great home control device.
Is your Motorola MC3190 configured to Turn Off if it is running on Battery Power? Will it ever turn off if on External Power?
NOTE: I had to post as answer to show image, but this isn't really an answer.
EDIT: If this is what you are interested in, consider reading the device's SystemState property. There are many members to SystemState, and one of them just may be what you are after.
There is no easy technique for what you are wanting to do, because the devices are designed to power down when not in use. If the battery goes dead, the devices have to be completely reset. Make sure this is what you want to do, because there is a reason it is hard to get around.
You'll likely have to register for a BatteryStrength changed event (like >> THIS <<), then try to trick it somehow ...maybe by popping up a dialog box or simulating a key press.
You'll most likely need to P/Invoke some of the lower level coredll.dll functionality (examples >> HERE <<) to get what you want, as this stuff doesn't come wrapped up in the standard WinMobile SDK.
EDIT 2: Here's a Great example that someone wrote to read and control as much of the Power State as possible: techlicity blog I liked it so much I've copied the code to a class in my Mobile Project!

How to continue execution when mobile device sleeps?

I'm developing an application that needs to execute until a count down. When the handled turns off the screen, the countdown halts. How can I continue the execution when this situation happens?
I assume you mean that you want your code to continue executing after the device suspends? First off, you can't. When the device suspends, the processor stops running. You have a couple options though. You can periodically call SystemIdleTimerReset to prevent the device from suspending, run it in "unattended mode" so the backlight shuts off but the device does not suspend, or use an API like CeRunAppAtTime to preiodically wake the processor to run your code.
Note that there's an article on CodeProject.com that contains examples of managed (C#) code for using the Windows Mobile powermanagement features.
http://www.codeproject.com/KB/mobile/WiMoPower1.aspx
Additionally information on starting an application due to various conditions from managed code can be found in a CodeProject.com article too.
http://www.codeproject.com/KB/mobile/WiMoAutostart.aspx
There is another way - some "cheating method": Disable sleep mode in Windows Mobile 6. It uses SystemIdleTimerReset and additionally simulates a key touch.

Categories

Resources