Timer Control in APS.NET ?

Discussion in 'ASP .Net' started by abhishek007p@hotmail.com, Mar 2, 2006.

  1. Guest

    HI,

    i am using visual web developer for .net 2.0.

    does .NET 2.0 comes with a timer control, i was unable to find it in
    the IDE, where is it ?


    thanks,
    Abhishek
     
    , Mar 2, 2006
    #1
    1. Advertising

  2. Peter Bromberg posted this Rob Howard sample a few days ago :

    using System;
    using System.Web;
    using System.Threading;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;

    namespace BlackbeltBLL {
    public class BackgroundService : IHttpModule {
    static Timer timer;
    int interval = 5000;
    public String ModuleName {
    get { return "BackgroundService"; }
    }

    public void Init(HttpApplication application) {
    // Wire-up application events
    if (timer == null)
    timer = new Timer(new TimerCallback(ScheduledWorkCallback), application.Context, interval, interval);
    }

    public void Dispose() {
    timer = null;
    }

    private void ScheduledWorkCallback (object sender) {
    HttpContext context = (HttpContext) sender;
    Poll(context);
    }

    void DoSomething (HttpContext context) {
    }

    #region DB Poll
    void Poll (HttpContext context) {
    SqlConnection connection = new SqlConnection(ConfigurationSettings.AppSettings["Northwind"]);
    SqlCommand command = new SqlCommand("SELECT * FROM changenotification", connection);
    SqlDataReader reader;
    string key = ConfigurationSettings.AppSettings["SqlDependency"];
    connection.Open();
    reader = command.ExecuteReader();
    while (reader.Read()) {
    string tableKey = String.Format(key, reader["Table"]);
    if (context.Cache[tableKey] != null) {
    int changeKey = int.Parse( context.Cache[ String.Format(key, reader["Table"])].ToString() );
    if (changeKey != int.Parse(reader["ChangeID"].ToString() ))
    context.Cache.Remove(tableKey);
    }
    }
    connection.Close();
    }
    #endregion
    }
    }

    ---000---




    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en espaƱol : http://asp.net.do/foros/
    ===================================
    <> wrote in message news:...
    > HI,
    >
    > i am using visual web developer for .net 2.0.
    >
    > does .NET 2.0 comes with a timer control, i was unable to find it in
    > the IDE, where is it ?
    >
    >
    > thanks,
    > Abhishek
    >
     
    Juan T. Llibre, Mar 2, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven
    Replies:
    1
    Views:
    1,664
    Simon
    Jul 9, 2003
  2. Guenther Liebowitz
    Replies:
    2
    Views:
    374
  3. Rick Strahl [MVP]
    Replies:
    0
    Views:
    400
    Rick Strahl [MVP]
    Aug 15, 2003
  4. George Ter-Saakov

    Re: Error reading from Access aps.net 1.1.

    George Ter-Saakov, Aug 19, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    418
    Alexander M. Polak
    Aug 19, 2003
  5. =?Utf-8?B?QmFyZW4=?=

    Aps.NET Calendar control Background

    =?Utf-8?B?QmFyZW4=?=, Mar 18, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,505
    =?Utf-8?B?QmFyZW4=?=
    Mar 20, 2006
Loading...

Share This Page