.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> Threading >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Threading in C# - Make it easy with Code

Posted By:Gaurav Arora       Posted Date: April 27, 2009    Points: 10    Category: Threading    URL: http://www.dotnetspark.com  

The following code-snippet gives a keen look on the simplest part of Thread in C# :

using System;

using System.Threading;

namespace CSharp.AStepAhead.threading


class threading


public threading()


//Thread th = new Thread(new ThreadStart(writeData("Gaurav")));



public static string nm;

public static int i;

protected static void writeData()


//string str;

for (i = 0; i <= nm.Length - 1; i++)


Console.ForegroundColor = ConsoleColor.Blue;


Console.WriteLine(" {0}", nm.Substring(i, 1));




static void Main()


string name, lname;

Console.Write("Enter First Name : ");

name = Console.ReadLine();

Console.Write("Enter Last Name : ");

lname = Console.ReadLine();

threading.nm = lname;


Thread th = new Thread(new ThreadStart(writeData));


for (int j = 0; j <= name.Length - 1; j++)


Console.ForegroundColor = ConsoleColor.Green;

Console.Write(" {0}", name.Substring(j, 1));









Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend