PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

EventWaitHandler

 
 
crino
Guest
Posts: n/a
 
      16th Mar 2005
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
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      16th Mar 2005
First, post the actual code. There are several syntax errors in what you've
posted (like it's OpenNETCF, not OpenNET and we have no ThreadStart), so I
know it won't run. Second, what is the value of 'nextrun'? Did you try it
using Now with a timespan of say 30 seconds added?

-Chris


"crino" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
cseverini@gmail.com
Guest
Posts: n/a
 
      16th Mar 2005
hi ctacke,
sorry the namespace is OpenNETCF

the nextrun value change everytime the function calculates the new time
with the arguments

i get the code from:
http://vault.netcf.tv/VaultService/VaultWeb/login.aspx in
'Sample/Notification'
but this application too didn't works correctly !?!

ps: the code is compiled correctly

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Mar 2005
Well that code does work, in general. Most likely, whatever you are doing
to calculate when to fire the event is responsible. Set the target time to
5 minutes into the future and verify, in that case, whether the event is set
initially or not. If you ask for an event that is close enough to the
current time that it's within the resolution of the alarm, the event is set
immediately.

Paul T.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi ctacke,
> sorry the namespace is OpenNETCF
>
> the nextrun value change everytime the function calculates the new time
> with the arguments
>
> i get the code from:
> http://vault.netcf.tv/VaultService/VaultWeb/login.aspx in
> 'Sample/Notification'
> but this application too didn't works correctly !?!
>
> ps: the code is compiled correctly
>



 
Reply With Quote
 
crino
Guest
Posts: n/a
 
      16th Mar 2005
I tried the sample application.....but, i repeat, the event start
immediatly...also if i set 5 minutees delay!?
In my app i set the event the day after....and it's fired immediatly



"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com> ha
scritto nel messaggio news:(E-Mail Removed)...
> Well that code does work, in general. Most likely, whatever you are doing
> to calculate when to fire the event is responsible. Set the target time
> to 5 minutes into the future and verify, in that case, whether the event
> is set initially or not. If you ask for an event that is close enough to
> the current time that it's within the resolution of the alarm, the event
> is set immediately.
>
> Paul T.
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> hi ctacke,
>> sorry the namespace is OpenNETCF
>>
>> the nextrun value change everytime the function calculates the new time
>> with the arguments
>>
>> i get the code from:
>> http://vault.netcf.tv/VaultService/VaultWeb/login.aspx in
>> 'Sample/Notification'
>> but this application too didn't works correctly !?!
>>
>> ps: the code is compiled correctly
>>

>
>



 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Mar 2005
I don't know what to tell you. I just ran it, too, and it works perfectly,
right out of Vault. Make sure that you are creating an event name of the
right format. In fact, just use the source *exactly* as it is in the source
control system. You're compiling the latest OpenNETCF source, too, right?
How are you triggering the wait in the sample? What value in the edit box?
Which radio button? Have you stepped into the various calls that occur to
OpenNETCF methods in the thread to make sure that they look reasonable?

Paul T.

"crino" <(E-Mail Removed)> wrote in message
news:q1ZZd.1070464$(E-Mail Removed)...
>I tried the sample application.....but, i repeat, the event start
>immediatly...also if i set 5 minutees delay!?
> In my app i set the event the day after....and it's fired immediatly
>
>
>
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> ha scritto nel messaggio news:(E-Mail Removed)...
>> Well that code does work, in general. Most likely, whatever you are
>> doing to calculate when to fire the event is responsible. Set the target
>> time to 5 minutes into the future and verify, in that case, whether the
>> event is set initially or not. If you ask for an event that is close
>> enough to the current time that it's within the resolution of the alarm,
>> the event is set immediately.
>>
>> Paul T.
>>
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> hi ctacke,
>>> sorry the namespace is OpenNETCF
>>>
>>> the nextrun value change everytime the function calculates the new time
>>> with the arguments
>>>
>>> i get the code from:
>>> http://vault.netcf.tv/VaultService/VaultWeb/login.aspx in
>>> 'Sample/Notification'
>>> but this application too didn't works correctly !?!
>>>
>>> ps: the code is compiled correctly
>>>

>>
>>

>
>



 
Reply With Quote
 
crino
Guest
Posts: n/a
 
      16th Mar 2005
Paul, Peter can i send you my example app?

thanx in advance

ps: i tried to post here the attachment but the server had locked it!?
......i belive



"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com> ha
scritto nel messaggio news:e%(E-Mail Removed)...
>I don't know what to tell you. I just ran it, too, and it works perfectly,
>right out of Vault. Make sure that you are creating an event name of the
>right format. In fact, just use the source *exactly* as it is in the
>source control system. You're compiling the latest OpenNETCF source, too,
>right? How are you triggering the wait in the sample? What value in the
>edit box? Which radio button? Have you stepped into the various calls that
>occur to OpenNETCF methods in the thread to make sure that they look
>reasonable?
>
> Paul T.
>
> "crino" <(E-Mail Removed)> wrote in message
> news:q1ZZd.1070464$(E-Mail Removed)...
>>I tried the sample application.....but, i repeat, the event start
>>immediatly...also if i set 5 minutees delay!?
>> In my app i set the event the day after....and it's fired immediatly
>>
>>
>>
>> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
>> ha scritto nel messaggio news:(E-Mail Removed)...
>>> Well that code does work, in general. Most likely, whatever you are
>>> doing to calculate when to fire the event is responsible. Set the
>>> target time to 5 minutes into the future and verify, in that case,
>>> whether the event is set initially or not. If you ask for an event that
>>> is close enough to the current time that it's within the resolution of
>>> the alarm, the event is set immediately.
>>>
>>> Paul T.
>>>
>>> <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> hi ctacke,
>>>> sorry the namespace is OpenNETCF
>>>>
>>>> the nextrun value change everytime the function calculates the new time
>>>> with the arguments
>>>>
>>>> i get the code from:
>>>> http://vault.netcf.tv/VaultService/VaultWeb/login.aspx in
>>>> 'Sample/Notification'
>>>> but this application too didn't works correctly !?!
>>>>
>>>> ps: the code is compiled correctly
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      16th Mar 2005
Just use the sample code directly from OpenNETCF. It's a known-good
starting point. If it works, then you can proceed from there. If it
doesn't work, we need to look at your hardware and the OS running on it.

Paul T.

"crino" <(E-Mail Removed)> wrote in message
news:5E0_d.664396$(E-Mail Removed)...
> Paul, Peter can i send you my example app?
>
> thanx in advance
>
> ps: i tried to post here the attachment but the server had locked it!?
> .....i belive
>
>
>
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> ha scritto nel messaggio news:e%(E-Mail Removed)...
>>I don't know what to tell you. I just ran it, too, and it works
>>perfectly, right out of Vault. Make sure that you are creating an event
>>name of the right format. In fact, just use the source *exactly* as it is
>>in the source control system. You're compiling the latest OpenNETCF
>>source, too, right? How are you triggering the wait in the sample? What
>>value in the edit box? Which radio button? Have you stepped into the
>>various calls that occur to OpenNETCF methods in the thread to make sure
>>that they look reasonable?
>>
>> Paul T.
>>
>> "crino" <(E-Mail Removed)> wrote in message
>> news:q1ZZd.1070464$(E-Mail Removed)...
>>>I tried the sample application.....but, i repeat, the event start
>>>immediatly...also if i set 5 minutees delay!?
>>> In my app i set the event the day after....and it's fired immediatly
>>>
>>>
>>>
>>> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
>>> ha scritto nel messaggio news:(E-Mail Removed)...
>>>> Well that code does work, in general. Most likely, whatever you are
>>>> doing to calculate when to fire the event is responsible. Set the
>>>> target time to 5 minutes into the future and verify, in that case,
>>>> whether the event is set initially or not. If you ask for an event
>>>> that is close enough to the current time that it's within the
>>>> resolution of the alarm, the event is set immediately.
>>>>
>>>> Paul T.
>>>>
>>>> <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> hi ctacke,
>>>>> sorry the namespace is OpenNETCF
>>>>>
>>>>> the nextrun value change everytime the function calculates the new
>>>>> time
>>>>> with the arguments
>>>>>
>>>>> i get the code from:
>>>>> http://vault.netcf.tv/VaultService/VaultWeb/login.aspx in
>>>>> 'Sample/Notification'
>>>>> but this application too didn't works correctly !?!
>>>>>
>>>>> ps: the code is compiled correctly
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
cseverini@gmail.com
Guest
Posts: n/a
 
      17th Mar 2005
so....
i've installed Vault client and re-downloaded the Notification example,
re-compilated the solution and
both in emulator and in my Qtek S100 (jam i-mate ...) the function is
raised immediatly
During the debug the code goes on even WaitOne().....i think that this
function has to wait the event is fired rigth?
instead the code call WaitOne and goes on immediatly so the function is
called
Please help me .... i can't continue my application without this
feature

if you want you can send me the version which works to you (source and
exe).
Thanx again


ps: http://www.pocket.at/ppc3/htcm.htm here you can find all my
hardware spec

 
Reply With Quote
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      17th Mar 2005
If you have SDF v1.2 installed on your development machine you may have
problems since this sample relies on functionality added since v1.2 - which
is why you need the latest source from the vault. Try renaming all the
OpenNETCF.*.dlls in C:\Program Files\Microsoft Visual Studio .NET
2003\CompactFrameworkSDK\v1.0.5000\Windows CE and then deploy Paul's sample
application. All being well this should deploy the v1.3 versions and work
correctly.

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> so....
> i've installed Vault client and re-downloaded the Notification example,
> re-compilated the solution and
> both in emulator and in my Qtek S100 (jam i-mate ...) the function is
> raised immediatly
> During the debug the code goes on even WaitOne().....i think that this
> function has to wait the event is fired rigth?
> instead the code call WaitOne and goes on immediatly so the function is
> called
> Please help me .... i can't continue my application without this
> feature
>
> if you want you can send me the version which works to you (source and
> exe).
> Thanx again
>
>
> ps: http://www.pocket.at/ppc3/htcm.htm here you can find all my
> hardware spec
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 AM.