Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows mobile threading.timer in unattenededmode
    text
    copied!<p>I have a windows mobile 6.5 program which I want to trigger a call to a web server every ten minutes. But the event doesn't seem to be always being called. I have create a simple program to test when events are being triggered.</p> <p>A threading.timer is set to execute every 10 seconds and then store the time in a string. I am trying to set a requirement for unattended mode so that this timer would continue to execute when the power button on the device is clicked or when the device is idle.</p> <p>When I am clicking the power button on the device the timer stops executing.</p> <pre><code>Imports System.Threading Imports Win32 Public Class Form1 Dim time As String = "" Dim tmrUploadTimerThread As Timer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, -1) tmrUploadTimerThread = New Timer(New TimerCallback(AddressOf Timer_Worker), Nothing, 10000, 10000) End Sub Private Sub Timer_Worker() time = Now &amp; Environment.NewLine &amp; time End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = time End Sub Private Sub Form1_Closed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Closed CoreDLL.PowerPolicyNotify(PPNMessage.PPN_UNATTENDEDMODE, 0) Me.Dispose() Application.Exit() End Sub </code></pre> <p>End Class</p> <p>I got the class Win32 from <a href="http://www.codeproject.com/Articles/28886/Windows-Mobile-Power-Management" rel="nofollow">Windows Mobile Power Management</a>. Bellow is the code for PowerPolicyNotify:</p> <pre><code>[DllImport("CoreDLL")] public static extern int PowerPolicyNotify( PPNMessage dwMessage, int option // DevicePowerFlags); ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload