1/52
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Exception
Is represented by classes. All the exceptions are subclasses in the built-in exception
ApplicationException (Type of Exceptions)
These exceptions are user program-generated
SystemException (Type of Exceptions)
These exceptions are generated by Common Language Runtime (CLR)
System.Exception
This is at the top of the standards’ exceptions hierarchy. The runtime system in C# generates all the exceptions.
System.ArithmeticException
Errors in arithmetic or conversion operation will be thrown in this exception.
System.OverflowException
When an overflow occurs in a checked operation, it will be thrown in this exception
System.ArgumentException
Any invalid argument in a method will be thrown in this exception.
System.ArgumentNullException
If there is an unacceptable argument passed to a method, it will be thrown in this exception
System.IndexOutOfRangeException
Throw in this exception when attempting to index an array through an index that is either less than zero or greater than the maximum length of index
System.OutOfMemoryException
If the available memory becomes too low to accommodate a memory allocation request, it will be thrown in this exception
System.StackOverflowException
Called when the execution stack is exhausted by having too many pending method callsSystem.FormatException
System.FormatException
Checks format of the string or argument if it is invalid
Try
This keyword is used to check for the occurrence of any exceptions enclosed to it
Catch
This keyword catches the exception that is thrown on the occurrence of exception in a try block
Throw
It is used to throw an exception manually
Finally
This keyword executes a given statement even if the exception is thrown or not thrown. This block cannot transfer control by using break, continue, return, or goto.
Create a try-catch-finally block
try{
//code
}
catch(typeOfException varName){
//code
}
finally{
//code
}
Create a throw exception
throw new exception_Object;
Create own exception
public class customizeException: Exception{
//code
}
Thread (Life Cycle of a Thread)
Can be found in the System.Threading namespace
Main Thread (Life Cycle of a Thread)
When using the Thread class, the first thread to be performed in a process is known as the main thread.
Child Thread (Life Cycle of a Thread)
Creating a child thread for the main thread should write or create a delegate object
Create a main thread
Thread mainThread = Thread.CurrentThread;
mainThread.Name = “Main Thread"
Create a Child Thread
ThreadStart delThread = new ThreadStart(ChildThreadMethod);
Thread childThread = new Thread(delThread);
Unstarted (Life Cycle of a Thread Harwani 2015)
A new thread begins its life cycle
Start (Life Cycle of a Thread Harwani 2015)
The thread remains in the Unstarted state until the Thread method _____ is called
Running (Life Cycle of a Thread Harwani 2015)
The Highest priority Started thread enters the ____ state
Abort (Life Cycle of a Thread Harwani 2015)
A Running thread enters the Stopped state when its job or task is over. Also, a running thread can be forced to the Stopped state by calling the ____ method.
Blocked (Life Cycle of a Thread Harwani 2015)
A thread enters _____ state when the thread issues an input/output request
Started (Life Cycle of a Thread Harwani 2015)
After I/O operations are complete, the Blocked thread returns to the ____ state
WaitSleepJoin (Life Cycle of a Thread Harwani 2015)
A Running thread may enter the ____ state either when it is asked to sleep for the specified number of milliseconds
Pulse (Life Cycle of a Thread Harwani 2015)
The ____ method moves the next waiting thread back to the Started state.
PulseAll (Life Cycle of a Thread Harwani 2015)
The _____ method moves all waiting threads back to the Started state.
Unstarted (List of Thread States)
A thread is created within the Common Language Runtime (CLR) but has not started
Ready (List of Thread States)
A thread is ready to run and is waiting for the CPU time
Running (List of Thread States)
A thread is in running mode after invoking its Start method.
WaitSleepJoin (List of Thread States)
A running thread is suspended temporarily by invoking either the Sleep method or the monitor’s Wait method
Started (List of Thread States)
A suspended thread resumes to Started state when the conditions for which is it was suspended are no longer valid.
Blocked (List of Thread States)
A thread is blocked when it is waiting for a resource or I/O operations
Stopped (List of Thread States)
A thread has finished its task.
CurrentThread (Properties of Thread Class)
It returns the current thread that is running
IsAlive (Properties of Thread Class)
It returns a Boolean value indicating the execution status of the recent thread.
IsBackground (Properties of Thread Class)
It is used to get or set a value that indicates whether the thread is a background thread
Name (Properties of Thread Class)
It is used to get or set the name of the thread
Priority (Properties of Thread Class)
It is used to get or set a value that represents the priority of a thread
ThreadState (Properties of Thread Class)
It is used to get the value that contains the states of the recent thread
public void Abort() (Methods of Thread Class)
It terminates the thread when calling this method and raises ThreadAbortException in the Thread
public void Interrupt() (Methods of Thread Class)
It interrupts the thread that is in the state of WaitSleepJoin
public void Join() (Methods of Thread Class)
It is used to stop the calling thread until a thread terminates
public static void ResetAbort() (Methods of Thread Class)
It is used to withdraw an abort request for the ongoing thread
public void Start() (Methods of Thread Class)
It is used to start a thread
public static void Sleep() (Methods of Thread Class)
It is used to pause a thread for the stated number of milliseconds
Multithreading
The CPU is assigned to each thread for a time slice before moving to the next thread.