| Next Tip?
Home » CSharp, Interview Questions, Tutorial

Threading in CSharp – Easier to write

28 October 2008 564 views One Comment
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Threading in C# – Easier to write
It’s a subsequent Code-Snippet of Article :Threading – A Step Ahead Story.
/* This Example is a part of different
* examples shown in Book:
* C#2005 Beginners: A Step Ahead
* Written by: Gaurav Arora
* Reach at : gaurav.aroraose@yahoo.co.in */
// File name : threading.cs
using System;
using System.Threading;
namespace CSharp.AStepAhead.threading
{
class threading
{
public threading()
{
//Thread th = new Thread(new ThreadStart(writeData("Gaurav")));
//th.Start();
}
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;
Thread.Sleep(1000);
Console.WriteLine(" {0}", nm.Substring(i, 1));
//Console.WriteLine(str);
}
}

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;
Console.Clear();
Thread th = new Thread(new ThreadStart(writeData));
th.Start();
for (int j = 0; j <= name.Length - 1; j++)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(" {0}",name.Substring(j,1));
Thread.Sleep(1000);
}
Console.ReadLine();
return;
}
}
}

Popularity: 6%

Post to Twitter Tweet This Post

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Ads by Lake Quincy Media

One Comment »

Leave your response!

You must be logged in to post a comment.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes