Friday 30 September 2011

What is .NET Remoting?


             .NET remoting is replacement of DCOM. Using .NET remoting you can make remote object calls which lie in different Application Domains. As the remote objects run in different process calling the remote object can not call it directly. So the client uses a proxy which looks like a real object.
 When client wants to make method call on the remote object it uses proxy for it. These method    calls   are called as "Messages". Messages are serialized using "formatter" class and sent to client "    channel". Client Channel communicates with Server Channel. Server Channel uses as formatter to deserialize the message and sends to the remote object

What are ManualResetEvent and AutoResetEvent?


                     Threads that call one of the wait methods of a synchronization event must wait until another thread signals the event by calling the Set method. There are two synchronization event classes. Threads set the status of ManualResetEvent instances to signaled using the Set method. Threads set the status of ManualResetEvent instances to no signaled using the Reset method or when control returns to a waiting WaitOne call. Instances of the AutoResetEvent class can also be set to signaled using Set, but they automatically return to nonsignaled as soon as a waiting thread is notified that the event became signaled.

What are Wait handles and a Mutex object?


                 Wait handles sends signals of a thread status from one thread to other thread. There are three kind of wait modes : WaitOne, WaitAny, WaitAll.
                 When a thread wants to release a Wait handle it can call Set method. You can use Mutex (mutually exclusive) objects to avail for the following modes. Mutex objects are synchronization objects that can only be owned by a single thread at a time. Threads request ownership of the mutex object when they require exclusive access to a resource. Because only one thread can own a mutex object at any time, other threads must wait for ownership of a Mutex object before using the resource.
                The WaitOne method causes a calling thread to wait for ownership of a mutex object. If a thread terminates normally while owning a mutex object, the state of the mutex object is set to be signaled and the next waiting thread gets ownership.

What is a Monitor object?


       Monitor objects are used to ensure that a block of code runs without being interrupted by code running on other threads. In other words, code in other threads cannot run until code in the synchronized code block has finished.
      SyncLock and End SyncLock statements are provided in order to simplify access to monitor object.

What is Interlocked class?


Interlocked class provides methods by which you can achieve following functionalities in a synchronization mode:
 Increment Values. 
 Decrement values.
  Exchange values between variables.
  Compare values from any thread.
Example : System.Threading.Interlocked.Increment(intVal)

What is Thread.Join() in threading?


There are two versions of Thread.Join():
 Thread.Join().
Thread.Join(Integer) this returns a Boolean value.
The Thread.Join() method is useful for determining if a thread has completed before starting another task. The Join() method waits a specified amount of time for a thread to end. If the thread ends before the time-out, Join() returns true; otherwise it returns False. Once you call Join(), the calling procedure stops and waits for the thread to signal that it is done.
Example you have "Thread1" and "Thread2" and while executing "Thread1" you call "Thread2.Join()".So "Thread1" will wait until "Thread2" has completed its execution and the again invoke "Thread1".
Thread.Join(Integer) ensures that threads do not wait for a long time. If it exceeds a specific time which is provided in integer the waiting thread will start