Timer Execution from App.Config RRS feed

  • Question

  • Hi Experts, 

    I wish to execute the below method say every 15- 30 seconds.

    Please support

    1. How can I set a timer object for this method.

    2. How can it be parameterize the timer frequency from from the App.config.

    3. If a session is already active shouldn't create a new session for the same. 

         public bool Start()
                return true;



    Thursday, November 28, 2019 8:03 AM


  • Hi Priya,

    Thank you for posting here.

    For your question, you want to set a timer for your method and read time interval from app.config.

    For the timer, the format of its callback method is certain, so I made some changes to your method.

    Here is a code example.

            static void Main(string[] args)
                int interval = int.Parse(ConfigurationManager.AppSettings["interval"]);
                System.Threading.Timer timer = new System.Threading.Timer(Start,null,1,interval);
            private static void Start(object state)
                Console.WriteLine("Do something here.");


    <?xml version="1.0" encoding="utf-8" ?>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
        <add key="interval" value="1500"/>

    Hope this could be helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 29, 2019 6:09 AM