V
verenadoll
Hello NG,
i use the following code to check if the device wakes up. It works
fine, but when i close the programm the process will not be
terminated. in the task manager the programm is listed as "background
process".
Whats wrong with the code.
Thanks and regards, Verena
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
Imports System.Runtime.InteropServices
Imports System.Threading
Imports OpenNETCF.WindowsCE.Notification
Imports OpenNETCF.Threading
Public Class Form1
'Declarations:
Public SyncEndEventThread As OpenNETCF.Threading.Thread2 = Nothing
Public NotificationEvent As OpenNETCF.Threading.EventWaitHandle =
Nothing
Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Create thread that monitors the Active Sync Event
SyncEndEventThread = New OpenNETCF.Threading.Thread2(New
ThreadStart(AddressOf HandlerNotifications))
End Sub
Public Sub HandlerNotifications()
Try
' Create event for notification.
NotificationEvent = New OpenNETCF.Threading.EventWaitHandle
(False, OpenNETCF.Threading.EventResetMode.AutoReset, "WakeupEvent")
' Set up notification.
Notify.RunAppAtEvent("\\.\Notifications\NamedEvents
\WakeupEvent",
OpenNETCF.WindowsCE.Notification.NotificationEvent.Wakeup)
While True
' Wait for the notification event to fire.
NotificationEvent.WaitOne()
' Let the notification subsystem know that we're done
with the event.
Notify.RunAppAtEvent("\\.\Notifications\NamedEvents
\WakeupEvent",
OpenNETCF.WindowsCE.Notification.NotificationEvent.None)
' Close event handle.
NotificationEvent.Close()
' Notify the user that the event fired.
Me.Invoke(New EventHandler(AddressOf Notify_Fired))
' Recreate the event for notification.
NotificationEvent = New
OpenNETCF.Threading.EventWaitHandle(False,
OpenNETCF.Threading.EventResetMode.AutoReset, "SyncEndEvent")
' Set up notification.
Notify.RunAppAtEvent("\\.\Notifications\NamedEvents
\WakeupEvent",
OpenNETCF.WindowsCE.Notification.NotificationEvent.Wakeup)
End While
Catch ex As Exception
MessageBox.Show("HandlerNotifications: " & ex.Message)
End Try
End Sub
Public Sub Notify_Fired(ByVal sender As System.Object, ByVal e As
System.EventArgs)
MessageBox.Show("The notification has fired.", "Notification")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
SyncEndEventThread.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
SyncEndEventThread.Suspend()
End Sub
End Class
i use the following code to check if the device wakes up. It works
fine, but when i close the programm the process will not be
terminated. in the task manager the programm is listed as "background
process".
Whats wrong with the code.
Thanks and regards, Verena
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
Imports System.Runtime.InteropServices
Imports System.Threading
Imports OpenNETCF.WindowsCE.Notification
Imports OpenNETCF.Threading
Public Class Form1
'Declarations:
Public SyncEndEventThread As OpenNETCF.Threading.Thread2 = Nothing
Public NotificationEvent As OpenNETCF.Threading.EventWaitHandle =
Nothing
Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Create thread that monitors the Active Sync Event
SyncEndEventThread = New OpenNETCF.Threading.Thread2(New
ThreadStart(AddressOf HandlerNotifications))
End Sub
Public Sub HandlerNotifications()
Try
' Create event for notification.
NotificationEvent = New OpenNETCF.Threading.EventWaitHandle
(False, OpenNETCF.Threading.EventResetMode.AutoReset, "WakeupEvent")
' Set up notification.
Notify.RunAppAtEvent("\\.\Notifications\NamedEvents
\WakeupEvent",
OpenNETCF.WindowsCE.Notification.NotificationEvent.Wakeup)
While True
' Wait for the notification event to fire.
NotificationEvent.WaitOne()
' Let the notification subsystem know that we're done
with the event.
Notify.RunAppAtEvent("\\.\Notifications\NamedEvents
\WakeupEvent",
OpenNETCF.WindowsCE.Notification.NotificationEvent.None)
' Close event handle.
NotificationEvent.Close()
' Notify the user that the event fired.
Me.Invoke(New EventHandler(AddressOf Notify_Fired))
' Recreate the event for notification.
NotificationEvent = New
OpenNETCF.Threading.EventWaitHandle(False,
OpenNETCF.Threading.EventResetMode.AutoReset, "SyncEndEvent")
' Set up notification.
Notify.RunAppAtEvent("\\.\Notifications\NamedEvents
\WakeupEvent",
OpenNETCF.WindowsCE.Notification.NotificationEvent.Wakeup)
End While
Catch ex As Exception
MessageBox.Show("HandlerNotifications: " & ex.Message)
End Try
End Sub
Public Sub Notify_Fired(ByVal sender As System.Object, ByVal e As
System.EventArgs)
MessageBox.Show("The notification has fired.", "Notification")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
SyncEndEventThread.Start()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
SyncEndEventThread.Suspend()
End Sub
End Class