unit3
unit3
C# Assemblies
What is an Assembly?
Assemblies are the building blocks of .NET applications, containing compiled code in the
form of Intermediate Language (IL).
Types of Assemblies:
using MyLibraryNamespace;
Definition:
gacutil -i MyAssembly.dll
3. Threads
Introduction to Threads
using System.Threading;
class Program
Console.WriteLine(i);
t.Start();
4. AppDomains
Definition:
Application Domains (AppDomains) are isolated environments for running .NET applications,
providing fault isolation and security boundaries.
Creating an AppDomain:
Console.WriteLine(domain.FriendlyName);
Unloading an AppDomain:
AppDomain.Unload(domain);
5. Processes Concepts
Definition:
A process is an executing instance of an application. Each process has its own memory space.
using System.Diagnostics;
class Program
Process.Start("notepad.exe");
lock (lockObject)
// Critical section
Monitors: Provide more control than lock by allowing Wait and Pulse.
Monitor.Enter(lockObject);
try
// Critical section
}
finally
Monitor.Exit(lockObject);
ReaderWriterLock
rwLock.EnterReadLock();
rwLock.ExitReadLock();
Mutexes
if (mutex.WaitOne())
try
// Critical section
finally
mutex.ReleaseMutex();
Thread Pooling
Definition:
o A pool of worker threads managed by .NET, reducing the overhead of creating new
threads.
Using ThreadPool:
ThreadPool.QueueUserWorkItem(state => {
});