PC Review


Reply
Thread Tools Rate Thread

Creating Events

 
 
Hoop
Guest
Posts: n/a
 
      7th Sep 2006
Hi,
I have a timer class and I would like to send an event based on specifc
times from the timer,
example at maybe every 500ms call a function, most likely a callback,
similar to the way the Systems.Timer works.
Is there a way one can create events to accomplish this?
Thanks
Jeff

 
Reply With Quote
 
 
 
 
senfo
Guest
Posts: n/a
 
      7th Sep 2006
There is already a timer class to do this. Is there any reason you
wanted to do it, yourself?

--
Sean
 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      7th Sep 2006
Hello Hoop,

Timer class supports System.Threading.TimerCallback callback
see http://msdn.microsoft.com/library/de...sctortopic.asp

H> Hi,
H> I have a timer class and I would like to send an event based on
H> specifc
H> times from the timer,
H> example at maybe every 500ms call a function, most likely a callback,
H> similar to the way the Systems.Timer works.
H> Is there a way one can create events to accomplish this?
H> Thanks
H> Jeff
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


 
Reply With Quote
 
Hoop
Guest
Posts: n/a
 
      7th Sep 2006
Hi Sean,
I have the timer class running allready. Resolution is only 55ms at
best.
I need something much faster, so I have HighRes timer class that I
would like somehow to be event driven in the same way as the timer.
Thought may there was a way to add user defined events.
Thanks
Jeff


senfo wrote:
> There is already a timer class to do this. Is there any reason you
> wanted to do it, yourself?
>
> --
> Sean


 
Reply With Quote
 
Hoop
Guest
Posts: n/a
 
      7th Sep 2006
Hi Michael,
I have tried System.Threading.Timer. Works much better than standard
windows timer. That is most likely what I will
wind up using. Was just trying to see if there was a way that I could
try this HighRes timer class
that I have.
Thanks
Jeff

Michael Nemtsev wrote:
> Hello Hoop,
>
> Timer class supports System.Threading.TimerCallback callback
> see http://msdn.microsoft.com/library/de...sctortopic.asp
>
> H> Hi,
> H> I have a timer class and I would like to send an event based on
> H> specifc
> H> times from the timer,
> H> example at maybe every 500ms call a function, most likely a callback,
> H> similar to the way the Systems.Timer works.
> H> Is there a way one can create events to accomplish this?
> H> Thanks
> H> Jeff
> ---
> WBR,
> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do not
> cease to be insipid." (c) Friedrich Nietzsche


 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      7th Sep 2006
Hello Hoop,

How much faster do u need? Windows is not real time OS. AFAIK the bottom
line is 20ms

H> Hi Michael,
H> I have tried System.Threading.Timer. Works much better than standard
H> windows timer. That is most likely what I will
H> wind up using. Was just trying to see if there was a way that I could
H> try this HighRes timer class
H> that I have.
H> Thanks
H> Jeff
H> Michael Nemtsev wrote:
H>
>> Hello Hoop,
>>
>> Timer class supports System.Threading.TimerCallback callback
>>
>> see
>> http://msdn.microsoft.com/library/de...ary/en-us/cpre
>> f/html/frlrfsystemthreadingtimerclassctortopic.asp
>>
>> H> Hi,
>> H> I have a timer class and I would like to send an event based on
>> H> specifc
>> H> times from the timer,
>> H> example at maybe every 500ms call a function, most likely a
>> callback,
>> H> similar to the way the Systems.Timer works.
>> H> Is there a way one can create events to accomplish this?
>> H> Thanks
>> H> Jeff
>> ---
>> WBR,
>> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
>> "At times one remains faithful to a cause only because its opponents
>> do not cease to be insipid." (c) Friedrich Nietzsche
>>

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


 
Reply With Quote
 
Hoop
Guest
Posts: n/a
 
      7th Sep 2006
Hi Michael,
Probably using the threading timer is maybe going to be OK, or maybe
just a thread and sleep() it for a some chosen time.
But I was trying to see if QueryPerformanceCounter() could beat it. I
have seen 15ms with the treading timer. A little jumpy but that might
work.
Thanks
Jeff

Michael Nemtsev wrote:
> Hello Hoop,
>
> How much faster do u need? Windows is not real time OS. AFAIK the bottom
> line is 20ms
>
> H> Hi Michael,
> H> I have tried System.Threading.Timer. Works much better than standard
> H> windows timer. That is most likely what I will
> H> wind up using. Was just trying to see if there was a way that I could
> H> try this HighRes timer class
> H> that I have.
> H> Thanks
> H> Jeff
> H> Michael Nemtsev wrote:
> H>
> >> Hello Hoop,
> >>
> >> Timer class supports System.Threading.TimerCallback callback
> >>
> >> see
> >> http://msdn.microsoft.com/library/de...ary/en-us/cpre
> >> f/html/frlrfsystemthreadingtimerclassctortopic.asp
> >>
> >> H> Hi,
> >> H> I have a timer class and I would like to send an event based on
> >> H> specifc
> >> H> times from the timer,
> >> H> example at maybe every 500ms call a function, most likely a
> >> callback,
> >> H> similar to the way the Systems.Timer works.
> >> H> Is there a way one can create events to accomplish this?
> >> H> Thanks
> >> H> Jeff
> >> ---
> >> WBR,
> >> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
> >> "At times one remains faithful to a cause only because its opponents
> >> do not cease to be insipid." (c) Friedrich Nietzsche
> >>

> ---
> WBR,
> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do not
> cease to be insipid." (c) Friedrich Nietzsche


 
Reply With Quote
 
Ben Voigt
Guest
Posts: n/a
 
      8th Sep 2006

"Hoop" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Sean,
> I have the timer class running allready. Resolution is only 55ms at
> best.
> I need something much faster, so I have HighRes timer class that I
> would like somehow to be event driven in the same way as the timer.
> Thought may there was a way to add user defined events.


Absolutely. Add the following inside your class:

public event EventHandler Expired;
private void CallInterestedParties()
{
if (Expired != null) Expired(/* sender */ this, /* EventArgs */
EventArgs.Empty);
}


> Thanks
> Jeff
>
>
> senfo wrote:
>> There is already a timer class to do this. Is there any reason you
>> wanted to do it, yourself?
>>
>> --
>> Sean

>



 
Reply With Quote
 
Ben Voigt
Guest
Posts: n/a
 
      8th Sep 2006
"Hoop" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Michael,
> Probably using the threading timer is maybe going to be OK, or maybe
> just a thread and sleep() it for a some chosen time.
> But I was trying to see if QueryPerformanceCounter() could beat it. I
> have seen 15ms with the treading timer. A little jumpy but that might
> work.
> Thanks
> Jeff


Waitable Timer, WaitForSingle/MultipleObject with a timeout, or select() all
should give better resolution. I have had 60 fps graphing using
MsgWaitForMultipleObjectsEx on a waitable timer in C++, and I think it could
have been smoother yet, but my graph only had room for 60 horizontal
pixels/second.

>
> Michael Nemtsev wrote:
>> Hello Hoop,
>>
>> How much faster do u need? Windows is not real time OS. AFAIK the bottom
>> line is 20ms
>>
>> H> Hi Michael,
>> H> I have tried System.Threading.Timer. Works much better than standard
>> H> windows timer. That is most likely what I will
>> H> wind up using. Was just trying to see if there was a way that I could
>> H> try this HighRes timer class
>> H> that I have.
>> H> Thanks
>> H> Jeff
>> H> Michael Nemtsev wrote:
>> H>
>> >> Hello Hoop,
>> >>
>> >> Timer class supports System.Threading.TimerCallback callback
>> >>
>> >> see
>> >> http://msdn.microsoft.com/library/de...ary/en-us/cpre
>> >> f/html/frlrfsystemthreadingtimerclassctortopic.asp
>> >>
>> >> H> Hi,
>> >> H> I have a timer class and I would like to send an event based on
>> >> H> specifc
>> >> H> times from the timer,
>> >> H> example at maybe every 500ms call a function, most likely a
>> >> callback,
>> >> H> similar to the way the Systems.Timer works.
>> >> H> Is there a way one can create events to accomplish this?
>> >> H> Thanks
>> >> H> Jeff
>> >> ---
>> >> WBR,
>> >> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
>> >> "At times one remains faithful to a cause only because its opponents
>> >> do not cease to be insipid." (c) Friedrich Nietzsche
>> >>

>> ---
>> WBR,
>> Michael Nemtsev :: blog: http://spaces.msn.com/laflour
>>
>> "At times one remains faithful to a cause only because its opponents do
>> not
>> cease to be insipid." (c) Friedrich Nietzsche

>



 
Reply With Quote
 
Hoop
Guest
Posts: n/a
 
      11th Sep 2006
Hi Sean,
Yes, that looks like what I want to try.
I am having trouble with setting up the event to run.

After adding that code to the HiResTimer(),
In my main form, pressureForm, in the constructor, I do

public pressureForm()
{
startTimer()
}

startTimer()
{
MyTimer.HiResTimer.Start();

//Error, the name Expired does not exist in the current context
MyTimer.HiResTimer.ElapasedTime += new EventHandler(Expired);

}

Must not be exact way to do it.
Jeff

Ben Voigt wrote:
> "Hoop" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Sean,
> > I have the timer class running allready. Resolution is only 55ms at
> > best.
> > I need something much faster, so I have HighRes timer class that I
> > would like somehow to be event driven in the same way as the timer.
> > Thought may there was a way to add user defined events.

>
> Absolutely. Add the following inside your class:
>
> public event EventHandler Expired;
> private void CallInterestedParties()
> {
> if (Expired != null) Expired(/* sender */ this, /* EventArgs */
> EventArgs.Empty);
> }
>
>
> > Thanks
> > Jeff
> >
> >
> > senfo wrote:
> >> There is already a timer class to do this. Is there any reason you
> >> wanted to do it, yourself?
> >>
> >> --
> >> Sean

> >


 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Custom Events Theresa Smallwood Microsoft Outlook 0 9th May 2006 04:07 PM
Creating my events. Daniel Groh Microsoft C# .NET 2 2nd May 2005 08:26 PM
Creating events in VB.net Jeffrey Spoon Microsoft VB .NET 4 11th Apr 2005 07:40 PM
Need help with creating a calendar of events =?Utf-8?B?Sm9l?= Microsoft ASP .NET 1 11th Jan 2005 01:45 AM
Creating events Juan Gabriel Del Cid Microsoft C# .NET 2 22nd Oct 2003 09:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:44 PM.