CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Question Help - I can't stopping my timer!

    I am implementing an image handler (IHttpHandler serving requests for jpg files) to be used in emails and record the recipient opening the email.

    e.g.

    <img src="http://www.mydomain.com/tracker.jpg?UID=12345" height="1" width="1" />

    I am also working on some code to time how long a user is actually spending reading the email. I've started a Timer (System.Timers.Timer) and that's happily ticking away, recording when the email is opened. BUT it doesn't stop when the email message is closed (It's obviously running on a thread) and my question is...

    Does anyone have any idea how I can get the timer to stop when the email is closed? I can't use javascript or any front end code because I'm serving an image request and have hit a dead end. Also, I'm unable to use any scripting in the email - most clients strip out javascript etc. so I need to keep it clean and do it this way.

    Thanks for any suggestions!

    code in use:


    public void ProcessRequest(System.Web.HttpContext context)
    {

    System.Timers.Timer myTimer = new System.Timers.Timer(10000);

    myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);

    myTimer.Start();

    }

    static void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
    // ... DB code here to record ticking
    }

  2. #2
    Join Date
    Nov 2010
    Posts
    42

    Re: Help - I can't stopping my timer!

    I do not really understand whats going on couldn't you create an event for when the email is close and: myTimer.Stop(); ?

  3. #3
    Join Date
    Dec 2010
    Posts
    2

    Resolved Re: Help - I can't stopping my timer!

    I've resolved the issue now - much easier to do something with the web logs.

    Thanks for looking

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured