Write the sample code for threading in c# .net..

Answer Posted / alcheringa

using system.threading;
// this is the function that we want to invoke in a new
thread

static void doit()
{
for (int i=0 ; i < 10; i++)
{
console.writeline("doing somethin");
}
}
// this is the main fucntion

public static void main()
{
// threadstart is the delegate
// we need to pass the method, ts accept's method name as
the parameter
threadstart ts=new threadstart(doit);
// this is how we define a new thread

thread tr=new thread(ts);
// we invoke the thread
tr.start()
conosle.readline();
}

Is This Answer Correct ?    22 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

HOW to Develope the CRUD(create,read,update,delete) FORM IN WINDOWS form by using c# only

512


What are Indexers in C#?

574


What is .cshtml file?

489


What is the example of predicate?

494


Explain the difference between Metadata and Manifest

537






What is code verification?

527


What do u mean by delegation?

530


What is sqladapter c#?

522


What do you mean by streamreader/streamwriter class in c#?

516


What is a .aspx file?

449


What is ispostback c#?

476


What is the difference between namespace and class?

430


For methods inside the interface why can’t you specify the accessibility modifier?

541


What is reflection c#?

464


I need code to connect ohter systems in the LAN and i want to display my website image over there and i want explain as a admin through phone. So i need code to access other system using C-Sharp. Any one please help me.Please give me the code. Advace thanks.

1455