Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Threading in c# .net

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-01-2011
Member
 
Join Date: Jan 2011
Posts: 42
Threading in c# .net
  

I am desktop application developer. I am currently working on c#. Nowadays I am working on a live project for one local company. Yesterday I come across one scenario where there is need to run multiple processes simultaneously just like keeping an process to running state but in background and performing other operations on front end. Is there any way to achieve same thing in case of programming in C#.net.

Reply With Quote
  #2  
Old 12-01-2011
Member
 
Join Date: May 2009
Posts: 620
Re: Threading in c# .net

Yes! I have a solution for keeping number of processes in background in running state. C# supports parallel execution of code through multithreading. When any process starts on a system it is treated as parent thread or primary thread. This primary thread process may run along with no. of child threads during working. A thread is an independent execution path, able to run simultaneously with other threads. A C# client program starts in single thread created automatically by CLR. CLR assigns each thread its own memory stack so that local variables are kept separate. So it is possible to keep number of processes simultaneously by assigning each process to new individual thread.
Reply With Quote
  #3  
Old 12-01-2011
Member
 
Join Date: Apr 2009
Posts: 567
Re: Threading in c# .net

Windows also follow the concept of threading to provide us the facility of multitasking. For using multitasking in your project you just need to add two namespaces in your solution which provides all the keywords and methods which you required to perform threading in your application. The namespaces that you need to add in your solutions are:-
  1. System
  2. System. Threading
After inheriting both these namespaces you just need to create an object of thread class and after creating an object pass the method that you want to execute along that thread.
Reply With Quote
  #4  
Old 12-01-2011
Member
 
Join Date: May 2009
Posts: 503
Re: Threading in c# .net

After starting the thread its "IsAlive" property returns true until the point where the thread ends. A thread ends when the delegate passed to the Thread’s constructor finishes executing. Once ended, a thread cannot start. But yes you can keep it as pending using Thread class sleep property. If more than one thread is working on a common or shared object than you have to use proper locking mechanism to avoid accident between two working threads. You can use conditional statements to check locking.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Threading in c# .net"
Thread Thread Starter Forum Replies Last Post
What is Hyper threading Ameeryan Overclocking & Computer Modification 2 06-10-2009 04:03 PM
What is Threading in C# Programming ? HAKAN Software Development 2 31-03-2009 11:18 AM
What is threading in JAVA? Arsenio Software Development 3 02-03-2009 08:29 PM
VB.NET threading question AmolP Software Development 3 14-02-2009 06:03 PM
Threading Unleashed Cool_Rahul Software Development 0 19-12-2008 01:39 PM


All times are GMT +5.5. The time now is 01:43 PM.