-
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.
-
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.
-
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:-
- System
- 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.
-
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.
Page generated in 1,713,970,716.86206 seconds with 11 queries