Threads in C# programming

September 30th, 2008

1. C# Threads Example 1
using System.Threading;
public class yyy
{
public void abc()
{
for ( int i = 0; i< =3;i++)
{
System.Console.Write(i + ” “);
}
}
public void pqr()
{
for ( int i = 0; i<=3;i++)
{
Thread.Sleep(1000);
System.Console.Write(i+ “…”);
}
}
}
public class zzz
{
public static void Main()
{
yyy a = new yyy();
Thread t = new Thread(new ThreadStart(a.abc));
Thread t1 = new Thread(new ThreadStart(a.pqr));
t.Start();
t1.Start();
}
}

2. Example 2 of threading in C Sharp (C#)
using System;
using System.Threading;

class App {
public static void Main() {

Console.WriteLine(” (Hit or Press Enter to terminate the sample)”);
Timer timer = new Timer(new TimerCallback(CheckStatus), null, 1, 2000);

Console.WriteLine(”Press Enter to close window”);
Console.Read();
}

// The callback method’s signature MUST match that of a System.Threading.TimerCallback
// delegate (it takes an Object parameter and returns void)
static void CheckStatus(Object state) {
Console.WriteLine(”Threads in C # sharp”);

}
}

Tip of the day script

September 9th, 2008

System Variables in C#

August 31st, 2008

Struct program in C#

July 25th, 2008

Static in C#

June 3rd, 2008

Basics of C#

May 14th, 2008

Reflection in c#

April 29th, 2008

Read from Web using C#

April 22nd, 2008

Sales Intimidator

March 31st, 2008

Popular web scripts

February 10th, 2008

Membership management script

January 27th, 2008

Download site creator script

January 17th, 2008

We wish you a Happy new year

January 1st, 2008

Read a file in C#

November 2nd, 2007

Joint Venture Firesale Automator

September 29th, 2007

Peel Away and Page peel ads.

July 8th, 2007

Helpdesk script

May 11th, 2007

SEO Niche sites creator script

March 11th, 2007

C# source code : Print page

January 21st, 2007

Pointers in C#

December 10th, 2006