C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Threading


Posted Date: 30 Sep 2008    Resource Type: Code Snippets    Category: Threading

Posted By: mahalakshmi       Member Level: Gold
Rating:     Points: 10



This sample shows you how to do threading.


class ThreadPriority
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
Console.WriteLine ("Priority: {0}", thread.Priority);
}
}

class ThreadPoolThread
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
Console.WriteLine ("IsThreadPoolThread: {0}",
thread.IsThreadPoolThread);
}
}
class ThreadAlive
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
Console.WriteLine ("IsAlive: {0}", thread.IsAlive);

}
}

class ThreadBackground
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
Console.WriteLine ("IsBackground: {0}",
thread.IsBackground);
}
}
class ThreadState
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
Console.WriteLine ("ThreadState: {0}",
thread.ThreadState);
}
}
class ThreadName
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
Console.WriteLine ("Name: {0}", thread.Name);
}
}
class ThreadName
{
public static void Main()
{
Thread thread = Thread.CurrentThread;
thread.Name = ".NET Thread";
}
}

class TimerCallBack
{
public static AutoResetEvent autoResetEvent
= new AutoResetEvent (false);
public static Timer timer = null;
public const int iterations = 4;

public class State
{
public int count = 0;
}

static void CallBack (Object stateObject)
{
State state = (State) stateObject;
Console.WriteLine ("{0} count = {1}", DateTime.Now, state.count++);
if (state.count > iterations)
{
timer.Dispose (autoResetEvent);
}
}

public static void Main()
{
timer = new Timer (new TimerCallback (CallBack), new State(),
1000, 2000);
autoResetEvent.WaitOne();
}
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Threading  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Thread Synchronisation in .Net using C#
Previous Resource: Threading in C# - Easier to write
Return to Discussion Resource Index
Post New Resource
Category: Threading


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use