none
how to tell an event time RRS feed

  • Question

  • Hi All,

    Is there a way to tell the actual time an event was fired? (not the time it's actually executing.)

    Thank you,

    Andy


    Nothin' but net, .Net that is...

    Wednesday, September 12, 2012 12:09 AM

Answers

  • NO. If you do not own the source code wherein the event is defined, then there is no way to know the exact time of event trigger.

    However, if you own the source code Or if you can request the owner of the source code, then it is possible. I mean the TimeStamp code can be logged or returned just before the event object is invoked.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Shweta Jain (Lodha) Wednesday, September 12, 2012 3:50 AM
    • Unproposed as answer by Andeezle Wednesday, September 12, 2012 6:07 AM
    • Proposed as answer by MasaSam Thursday, September 13, 2012 5:31 AM
    • Marked as answer by Mike FengModerator Monday, September 24, 2012 2:03 PM
    Wednesday, September 12, 2012 2:48 AM
  • As said by Adavesh there is no way to know it, unless you have the way to modify code before event is raised and log the timestamp. So you need the source code or optionally override method that raises the event.
    Wednesday, September 12, 2012 8:58 AM

All replies

  • NO. If you do not own the source code wherein the event is defined, then there is no way to know the exact time of event trigger.

    However, if you own the source code Or if you can request the owner of the source code, then it is possible. I mean the TimeStamp code can be logged or returned just before the event object is invoked.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Shweta Jain (Lodha) Wednesday, September 12, 2012 3:50 AM
    • Unproposed as answer by Andeezle Wednesday, September 12, 2012 6:07 AM
    • Proposed as answer by MasaSam Thursday, September 13, 2012 5:31 AM
    • Marked as answer by Mike FengModerator Monday, September 24, 2012 2:03 PM
    Wednesday, September 12, 2012 2:48 AM
  • Hi Andeezle,

    I agree with Adavesh. But if you really want to do this, then there is a workaround for this. Although this is not a good approach, but you can give a try: You can log the TimeStamp, where you are handling the event. For this, you have to own the source code of where the event is handled.


    Regards, http://www.shwetalodha.blogspot.in/

    • Proposed as answer by Shweta Jain (Lodha) Wednesday, September 12, 2012 3:50 AM
    • Unproposed as answer by Andeezle Wednesday, September 12, 2012 6:08 AM
    Wednesday, September 12, 2012 3:50 AM
  • As said by Adavesh there is no way to know it, unless you have the way to modify code before event is raised and log the timestamp. So you need the source code or optionally override method that raises the event.
    Wednesday, September 12, 2012 8:58 AM
  • I own the event handler only. the problem is that events are firing sometimes at a rate of 1 every .00001 seconds.  There may be times where the events buildup on the stack before they are executed. Therefore, using DateTime.Now to tell the time the event occured within the event handler itself, does not work.  Any suggestions to help resolve this issue are welcome. 

    Btw, what is meant by, TimeStamp ?  Is it a .NET FW class?  In the System.Diagnostics namespace?  Please elaborate.

    Why is it suggested above that it is not a good approach, please elaborate.

    Thank you,

    Andy


    Nothin' but net, .Net that is...

    Wednesday, September 12, 2012 4:26 PM
  • "firing sometimes at a rate of 1 every .00001 seconds."

    You've got serious problems.  Events are similar to interrupts on single task computers.  They should occur infrequently.  On a Windows computer, they shouldn't occur more freqently than needed to update the UI, which is approximately 50 ms.  Indiscrimate firing of events asynchronously can lead to the problem you describe.  For example a BackgroundWorker calling ReportProgress.  DoEvents is another source.

    Wednesday, September 12, 2012 6:13 PM
  • Btw, what is meant by, TimeStamp ?  Is it a .NET FW class?  In the System.Diagnostics namespace?  Please elaborate..

    Timestamp means a perticular time (at which event fires) like "09-12-2012 10:30:45 PM"

    And coming to ur original question, since you don't own the event, u cannot know the exact timing of event trigger.

    Also John's comment makes perfect sense. 1 event per 0.00001 seconds !! You might want to rethink of your design.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Thursday, September 13, 2012 2:39 AM
  • Timestamp means a perticular time (at which event fires) like "09-12-2012 10:30:45 PM"

    And coming to ur original question, since you don't own the event, u cannot know the exact timing of event trigger.

    Also John's comment makes perfect sense. 1 event per 0.00001 seconds !! You might want to rethink of your design.


    Please mark this post as answer if it solved your problem. Happy Programming!


    The word "TimeStamp" is not in the dictionary and when cased like you do implies a class name.  If you mean time stamp, then just write it that way.  I know what a time stamp is son.  And try to be less condescending in your tone.  Your last comment is worthless.  Why don't you suggest what exactly is a better design approach? 

    Nothin' but net, .Net that is...

    Thursday, September 13, 2012 9:07 PM
  • "firing sometimes at a rate of 1 every .00001 seconds."

    You've got serious problems.  Events are similar to interrupts on single task computers.  They should occur infrequently.  On a Windows computer, they shouldn't occur more freqently than needed to update the UI, which is approximately 50 ms.  Indiscrimate firing of events asynchronously can lead to the problem you describe.  For example a BackgroundWorker calling ReportProgress.  DoEvents is another source.


    50 ms is an eternity

    Nothin' but net, .Net that is...

    Thursday, September 13, 2012 9:08 PM
  • Hi Andeezle,

    The only way you can know when the actual event was fired is to get the time stamp right before the event gets fired. And for you to do that, you'll need access to modify the source code where the event fires. You can have some workarounds, but still that will not give you the actual time.

    And by the way, you should consider reducing the rate at which your events fire, because at the rate you just mentioned (1 event in every 0.00001 seconds), your application will have some serious performance problems.

    Regards,

    Abdul

    Friday, September 14, 2012 4:59 AM
  • Actually events that are "firing sometimes at rate of 1 every 0.00001 second" might not be bad design, that might depend on what kind of an event we are talking about. For example property changing/changed events can be raised very rapidly when object properties are modified, but then again there is long periods without those events. Still generally code that raises events rapidly all the time are not so common and should be designed and implemented other way, but Andeezle has said he can not change event raising so if other code raises events that often then it's possibly problem in that code design.

    Still the only way to know actual event time is modify the source code before event is raised or override the method that raises the event.

    Friday, September 14, 2012 5:10 AM