Sponsored Ad

Monday, November 9, 2009

C# .Net Tutorial Multithreading

Any Windows application should have three or more processes. A system is the structural unit of a block of memory and the use of a set of resources. For each executable, the Windows operating process creates a single memory block. This in C #. Net Tutorial tries to describe the basics of Multithreading in C #. NET. Each system must have at least three thread. The first thread is created with a system known as the main thread. The main entry point of this thread is applicable. In traditional Windows applications is the method WinMain () and console applications called main ( ).

Main objective of creating multithreaded applications is to improve performance. As an example, imagine a situation where a user starts a long process (copying, for example), can the 't use a single threaded application and wait an infinite time of the operation to get completed. But if you use multiple? Threaded application can be set in the copying process of the background and interact with the application without problems. First, if you want to create a multi-threaded an important point to remember is, a global variable that is being visited by different topics, you can try to modify the same variable. This is a generic problem that is resolved through a mechanism called thread synchronization. Timing is nothing but the process of creating a set of rules to operate data or resources.

The C #. NET namespace has a large scope that can be used for programming with threads and Thread Synchronization in C #. Internet programming. The name of the namespace is Sytem.Threading. The most important class in this namespace for manipulating the threads is the C #. Thread NET. You can run another thread in our implementation process.

Example:

Code Snippet
  1. //Sample for C# tutorial on Multithreading using lock
  2.  
  3.     public void Coundown()
  4.     {
  5.  
  6.         lock(this)
  7.         {
  8.  
  9.             for(int i=4;i>=0;i--)
  10.             {
  11.  
  12.                 Console.WriteLine("{0} seconds to start",i);
  13.  
  14.             }
  15.  
  16.             Console.WriteLine("GO!!!!!");
  17.  
  18.         }
  19.  
  20.     }

3 comments:

Sponsored Ad

Website Update

Followers