Error small example VB notify event

Last post 03-14-2007 2:45 by Anonymous. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-26-2005 4:53

    Error small example VB notify event

    Hi all

    I am building a small example VB application about event notify.
    It is based on opennect notify example, that run fine, but in my application I obtain a "Cannot run \\\\.\\Notifications\\NamedEvents\\OpenNETCFSampleNotifyEvent", and I dont know why??.

    Please, do you know what is wrong??

    Thanks in advance.


    This is my code:


    Imports OpenNETCF.Win32.Notify
    Imports OpenNETCF.Threading
    Imports System.Threading

    Public Class frmWakeUp2
    Inherits System.Windows.Forms.Form
    Friend WithEvents btnSalir As System.Windows.Forms.Button

    Public Reminder As OpenNETCF.Threading.ThreadEx = Nothing
    Public NotificationEvent As EventWaitHandle = Nothing
    Public Saliendo As Boolean = False

    #Region " Windows Form Designer generated code "

    Public Sub New()

    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    MyBase.Dispose(disposing)
    End Sub

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents btnActivarAlerta As System.Windows.Forms.Button
    Private Sub InitializeComponent()
    Me.btnSalir = New System.Windows.Forms.Button
    Me.btnActivarAlerta = New System.Windows.Forms.Button
    '
    'btnSalir
    '
    Me.btnSalir.Location = New System.Drawing.Point(32, 248)
    Me.btnSalir.Size = New System.Drawing.Size(168, 32)
    Me.btnSalir.Text = "Salir"
    '
    'btnActivarAlerta
    '
    Me.btnActivarAlerta.Location = New System.Drawing.Point(33, 200)
    Me.btnActivarAlerta.Size = New System.Drawing.Size(168, 32)
    Me.btnActivarAlerta.Text = "Activar Alerta"
    '
    'frmWakeUp2
    '
    Me.ClientSize = New System.Drawing.Size(234, 295)
    Me.Controls.Add(Me.btnActivarAlerta)
    Me.Controls.Add(Me.btnSalir)
    Me.Text = "Wake Up 2"

    End Sub

    Public Shared Sub Main()
    Application.Run(New frmWakeUp2)
    End Sub

    #End Region

    Public Sub HandlerNotifications()

    Try
    Dim runtime As DateTime = DateTime.Now
    runtime = runtime.AddSeconds(70)

    ' Create event for notification.
    NotificationEvent = New OpenNETCF.Threading.EventWaitHandle(False, OpenNETCF.Threading.EventResetMode.AutoReset, "OpenNETCFSampleNotifyEvent")

    ' Set up notification.
    Notify.RunAppAtTime("\\\\.\\Notifications\\NamedEvents\\OpenNETCFSampleNotifyEvent", runtime)

    While Not Saliendo
    ' Wait for the notification event to fire.
    NotificationEvent.WaitOne()

    ' Let the notification subsystem know that it's
    ' done with the event.
    Try
    Notify.RunAppAtTime("\\\\.\\Notifications\\NamedEvents\\OpenNETCFSampleNotifyEvent", DateTime.MinValue)
    Catch e As Exception
    MessageBox.Show("Error notify.runappattime")
    End Try

    ' Close event handle.
    NotificationEvent.Close()

    If Not Saliendo Then
    ' Notify the user that the event fired.
    Me.Invoke(New EventHandler(AddressOf Notify_Fired))

    ' Create event for notification.
    NotificationEvent = New OpenNETCF.Threading.EventWaitHandle(False, OpenNETCF.Threading.EventResetMode.AutoReset, "OpenNETCFSampleNotifyEvent")

    ' Set up notification.
    runtime = DateTime.Now.AddSeconds(70)
    Notify.RunAppAtTime("\\\\.\\Notifications\\NamedEvents\\OpenNETCFSampleNotifyEvent", runtime)

    'Else
    ' MessageBox.Show("Saliendo!!!!")
    End If
    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)
    ' The notify event fired. Notify the user.
    MessageBox.Show("The notification has fired.", "Notification")
    End Sub

    Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click
    Saliendo = True

    If Not IsNothing(Reminder) Then
    Dim notifyEvent As EventWaitHandle = New OpenNETCF.Threading.EventWaitHandle(False, OpenNETCF.Threading.EventResetMode.AutoReset, "OpenNETCFSampleNotifyEvent")

    ' Notify the thread to stop.
    notifyEvent.Set()
    notifyEvent.Close()

    System.Threading.Thread.Sleep(2000)
    Reminder = Nothing

    End If

    Application.Exit()
    End Sub

    Private Sub btnActivarAlerta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnActivarAlerta.Click
    Reminder = New OpenNETCF.Threading.ThreadEx(New ThreadStart(AddressOf HandlerNotifications))
    Reminder.Start()
    End Sub
    End Class
  • 08-26-2005 23:49 In reply to

    Re: Error small example VB notify event

    The system interprets the string as a file name and tries to start it as a program. Have a look at MSDN“s documentation on the naming rules you have to obey, in order to mark it as a system wide named event.

    Happy coding,
    ukiller
  • 08-27-2005 10:20 In reply to

    Re: Error small example VB notify event

    asdf,

    what a curious name you have. BTW: use @" insted " to start the definition of your string, you then don't have to double every \, but can instead specify it in a more "natural" way: @"\\.\Notifications\NamedEvents\OpenNETCFSampleNotifyEvent"

    Happy coding,
    ukiller
  • 08-28-2005 11:57 In reply to

    Re: Error small example VB notify event

    Why don't you do yourself a favor and isolate the bug down to the minimum lines necessary to reproduce it?

    I would write two programs instead of one. The first creates the named event and triggers it in 7 seconds (or whatever) from now. The second one waits for the named event to occur and signals this to the user. There could even be a third one that removes the named event once you are done.

    There exists an utility to view the registered named events, I just couldn't locate it on my harddisk and Google isn't any help here.

    Happy coding,
    ukiller
  • 08-29-2005 1:12 In reply to

    Re: Error small example VB notify event

    Hi ukiller,

    thanks for your responses.

    Well, I changed each double '\' by a single '\' and now the event is fired. Why OpenNET example use double '\'??

    My terminal (symbol mc9062 ppc 2003) is powered on (i hear it), but his screen not and I have to press the power button to view the notification.

    Somebody know why??
    Thanks in advance.

    Regards.

    ACP
  • 03-14-2007 2:45 In reply to

    Re: Error small example VB notify event

    Hi, acp;
    I am developing with Sumbol scanner MC9062B.
    Can we share some experience?
    My email: hu.qiuwei@gmail.com

    cheers.

    quote:
    Originally posted by acp

    Hi ukiller,

    thanks for your responses.

    Well, I changed each double '\' by a single '\' and now the event is fired. Why OpenNET example use double '\'??

    My terminal (symbol mc9062 ppc 2003) is powered on (i hear it), but his screen not and I have to press the power button to view the notification.

    Somebody know why??
    Thanks in advance.

    Regards.

    ACP



    qq
Page 1 of 1 (6 items)