C
crino
Hi,
i need to run a function at a specific time to switch the status of my
application.
I tried the code suggest by Peter but the EventWaitHandler.WaitOne()
didn't works properly....the function is raised immediately!?
Any clue??
Thanx in advance
this is my code:
private bool bAppExit = false;
private EventWaitHandle notifyStartEvent = null;
private OpenNET.Threading.ThreadEx threadStart = null;
public void ThreadProcStart()
{
SystemTime nextrun = GetNextDate(short.Parse(cboInitH.Text),
short.Parse(cboInitM.Text));
DateTime runtime = nextrun.ToDateTime();
// Create event for notification.
notifyStartEvent = new OpenNET.Threading.EventWaitHandle(false,
OpenNET.Threading.EventResetMode.AutoReset,
"CallStartEvent" );
// Set up notification.
Notify.RunAppAtTime(
"\\\\.\\Notifications\\NamedEvents\\CallStartEvent", runtime );
// Wait for the notification event to fire.
notifyStartEvent.WaitOne();
// Let the notification subsystem know that it's
// done with the event.
try
{
Notify.RunAppAtTime(
"\\\\.\\Notifications\\NamedEvents\\CallStartEvent", DateTime.MinValue
);
}
catch//(Exception ex)
{
}
// Close event handle.
notifyStartEvent.Close();
// If the event was fired because the application
// is exiting, do nothing else; just return.
if ( !bAppExit )
{
// Notify the user that the event fired.
this.Invoke( new EventHandler(ChangeState));
}
// Clear thread to indicate that we're done.
threadStart = null;
}
Thanx in advance
i need to run a function at a specific time to switch the status of my
application.
I tried the code suggest by Peter but the EventWaitHandler.WaitOne()
didn't works properly....the function is raised immediately!?
Any clue??
Thanx in advance
this is my code:
private bool bAppExit = false;
private EventWaitHandle notifyStartEvent = null;
private OpenNET.Threading.ThreadEx threadStart = null;
public void ThreadProcStart()
{
SystemTime nextrun = GetNextDate(short.Parse(cboInitH.Text),
short.Parse(cboInitM.Text));
DateTime runtime = nextrun.ToDateTime();
// Create event for notification.
notifyStartEvent = new OpenNET.Threading.EventWaitHandle(false,
OpenNET.Threading.EventResetMode.AutoReset,
"CallStartEvent" );
// Set up notification.
Notify.RunAppAtTime(
"\\\\.\\Notifications\\NamedEvents\\CallStartEvent", runtime );
// Wait for the notification event to fire.
notifyStartEvent.WaitOne();
// Let the notification subsystem know that it's
// done with the event.
try
{
Notify.RunAppAtTime(
"\\\\.\\Notifications\\NamedEvents\\CallStartEvent", DateTime.MinValue
);
}
catch//(Exception ex)
{
}
// Close event handle.
notifyStartEvent.Close();
// If the event was fired because the application
// is exiting, do nothing else; just return.
if ( !bAppExit )
{
// Notify the user that the event fired.
this.Invoke( new EventHandler(ChangeState));
}
// Clear thread to indicate that we're done.
threadStart = null;
}
Thanx in advance