Click here to Skip to main content
15,886,806 members
Articles / Programming Languages / C#

C# Date Time Parser

Rate me:
Please Sign up or sign in to vote.
4.72/5 (54 votes)
28 Jun 2012Public Domain4 min read 248.1K   2.5K   158  
Parsing date and (or) time from a string
using System;using System.Threading;

public class StaticThreads
{
    //testing static threads
    public static void Main1()
    {

        Thread myThread1 = new Thread(new
        ThreadStart(StaticThreads.DoSomething));
        Thread myThread2 = new Thread(new
        ThreadStart(StaticThreads.DoSomething));
        Thread myThread3 = new Thread(new
        ThreadStart(StaticThreads.DoSomething));

        myThread1.Name = "Thread 1";
        myThread2.Name = "Thread 2";
        myThread3.Name = "Thread 3";

        Console.WriteLine("Press ENTER to start,");
        Console.WriteLine("and ENTER again to stop.");
        Console.ReadLine();

        myThread1.Start();
        Thread.Sleep(300);
        myThread2.Start();
        Thread.Sleep(300);
        myThread3.Start();

        Console.ReadLine();
        myThread1.Abort();
        myThread2.Abort();
        myThread3.Abort();

    }

    public static void DoSomething()
    {
        while (true)
        {
            Console.WriteLine(Thread.CurrentThread.Name + DateTime.Now);
            Thread.Sleep(1000);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Architect CliverSoft (www.cliversoft.com)
Ukraine Ukraine
Sergey is graduated as applied mathematician. He is specialized in custom development including parsing tools, client/server applications.
github: https://github.com/sergeystoyan
site: http://cliversoft.com

Comments and Discussions