Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
GeneralRe: Convert DateTime to Date Pin
PIEBALDconsult1-Aug-08 5:32
mvePIEBALDconsult1-Aug-08 5:32 
GeneralRe: Convert DateTime to Date Pin
Verghese1-Aug-08 5:41
Verghese1-Aug-08 5:41 
GeneralRe: Convert DateTime to Date Pin
PIEBALDconsult1-Aug-08 15:25
mvePIEBALDconsult1-Aug-08 15:25 
GeneralRe: Convert DateTime to Date Pin
Verghese4-Aug-08 5:02
Verghese4-Aug-08 5:02 
AnswerRe: Convert DateTime to Date Pin
stancrm31-Jul-08 21:40
stancrm31-Jul-08 21:40 
QuestionMulti columns in Crystal Report Pin
mehrdadc4831-Jul-08 8:33
mehrdadc4831-Jul-08 8:33 
AnswerRe: Multi columns in Crystal Report Pin
Wendelius31-Jul-08 8:38
mentorWendelius31-Jul-08 8:38 
QuestionInstantiating a static class at application start? Pin
Duncan Edwards Jones31-Jul-08 6:02
professionalDuncan Edwards Jones31-Jul-08 6:02 
OK - I have created a static class to add a "heartbeat" to an application (in a similar way to the way Trace and Debug classes work) thus:-

    /// <summary>
    /// A class that allows an externally accessible hearbeat to be set for an application 
    /// </summary>
    public static class Heartbeat  
    {

        private static HeartbeatListenerCollection _listeners = new HeartbeatListenerCollection();

        /// <summary>
        /// Sends a heartbeat to any heartbeat monitors
        /// to indicate that the application is running
        /// </summary>
        public static void Beat()
        {
            // make each heartbeat listener beat 
            foreach (HeartbeatMonitorBase  _listener in Listeners)
            {
                _listener.Beat();
            }
        }


        /// <summary>
        /// Starts the heartbeat with a default frequency
        /// </summary>
        static Heartbeat()
        {
            // Fire up a thread to invoke hearbeat events 
            // perdiodically...
            TimerCallback timerDelegate =
            new TimerCallback(Heartbeat.Beat);

            AutoResetEvent autoEvent = new AutoResetEvent(false);

            System.Threading.Timer heartbeatTimer =
                new System.Threading.Timer(timerDelegate, autoEvent, 0,1000);
            

        }


        /// <summary>
        /// The listeners attached to the heartbeat
        /// </summary>
        /// <remarks >
        /// These should not be triggered directly but rather the 
        /// Heartbeat.Beat() method should be called
        /// </remarks>
        public  static HeartbeatListenerCollection Listeners
        {
            get { return Heartbeat._listeners; }
        }
    }
}


However this only gets started beating the first time the class is referred to. Does anybody have any thoughts as to how I could get this class to instantiate at startup?

'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd

AnswerRe: Instantiating a static class at application start? Pin
User 665831-Jul-08 6:20
User 665831-Jul-08 6:20 
GeneralRe: Instantiating a static class at application start? Pin
Duncan Edwards Jones31-Jul-08 6:29
professionalDuncan Edwards Jones31-Jul-08 6:29 
GeneralRe: Instantiating a static class at application start? Pin
User 665831-Jul-08 6:39
User 665831-Jul-08 6:39 
QuestionRe: Instantiating a static class at application start? Pin
Wendelius31-Jul-08 7:27
mentorWendelius31-Jul-08 7:27 
GeneralRe: Instantiating a static class at application start? Pin
PIEBALDconsult31-Jul-08 10:57
mvePIEBALDconsult31-Jul-08 10:57 
GeneralRe: Instantiating a static class at application start? Pin
Duncan Edwards Jones31-Jul-08 22:49
professionalDuncan Edwards Jones31-Jul-08 22:49 
GeneralRe: Instantiating a static class at application start? Pin
PIEBALDconsult1-Aug-08 3:19
mvePIEBALDconsult1-Aug-08 3:19 
AnswerRe: Instantiating a static class at application start? Pin
PIEBALDconsult1-Aug-08 5:13
mvePIEBALDconsult1-Aug-08 5:13 
QuestionDisappearing expand indicators on PropertyGrid Pin
rbuchana31-Jul-08 6:00
rbuchana31-Jul-08 6:00 
AnswerRe: Disappearing expand indicators on PropertyGrid Pin
Thomas Stockwell31-Jul-08 6:31
professionalThomas Stockwell31-Jul-08 6:31 
GeneralRe: Disappearing expand indicators on PropertyGrid [modified] Pin
rbuchana31-Jul-08 6:41
rbuchana31-Jul-08 6:41 
GeneralRe: Disappearing expand indicators on PropertyGrid Pin
Thomas Stockwell31-Jul-08 6:48
professionalThomas Stockwell31-Jul-08 6:48 
GeneralRe: Disappearing expand indicators on PropertyGrid Pin
rbuchana31-Jul-08 7:15
rbuchana31-Jul-08 7:15 
QuestionDo I need to check this.Disposed inside my get/set for properties, too? Pin
JoeRip31-Jul-08 5:07
JoeRip31-Jul-08 5:07 
GeneralRe: Do I need to check this.Disposed inside my get/set for properties, too? Pin
Simon P Stevens31-Jul-08 22:03
Simon P Stevens31-Jul-08 22:03 
AnswerRe: Do I need to check this.Disposed inside my get/set for properties, too? Pin
PIEBALDconsult1-Aug-08 6:09
mvePIEBALDconsult1-Aug-08 6:09 
AnswerRe: Do I need to check this.Disposed inside my get/set for properties, too? Pin
Scott Dorman2-Aug-08 15:16
professionalScott Dorman2-Aug-08 15:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.