Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Embed console with timer

 

Code example for creating a Consollen application with a timer

 

in Visual STudio 2019

Console in .Core

 

 

using System;

using System.Timers;

 

namespace ConsoleApp_Core2

{

    class Program

    {

        //< variables >

        static int iTimer = 0;

        static Timer timer = new Timer(1000);

        //</ variables >

 

        static void Main(string[] args)

        {

            //------< Main >------

           

            //create a timer

            timer.Elapsed += Timer_Elapsed;

           

            //< init >

            timer.Start();

            Console.WriteLine("Start reading");

            //</ init >

 

            //wait until enter any key

            Console.ReadLine();

 

            //stop timer when closing console

            timer.Stop();

            //------<// Main >------

        }

 

 

        #region events

        private static void Timer_Elapsed(object sender, ElapsedEventArgs e)

        {

            //---------< Timer_Elapsed() >------

            iTimer++;

            Console.WriteLine(iTimer + " " + DateTime.Now );        //write loop and time to console output

 

            // clear

            GC.Collect(); //*???

            //---------</ Timer_Elapsed() >------

        }

 

        #endregion / events

    }

}

 

 

Mobile
»
Create a Console App with Timer
»
Synchronize Azure DevOps with local code directory
»
Edit data in SQL query, on SQL Server Management Studio SSMS
»
SQL Server: Copying a table
»
SQL Server: Saving changes is not allowed.
»
SQL Server: Cancel Single User Mode
»
SQL Server: Datenbank kopieren mit Zwischenspeicher Teil 2 von 2
»
SQL Server: Datenbank kopieren mit Zwischenspeicher Teil 1 von 2
»
SQL Server: Datenbank Daten exportieren, Datenbank kopieren
»
Installation der SQLExpress Server Instanz

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de