Sunday, March 22, 2009
ASP DOT NET - Objective Questions
ASP Dot Net
1) Which of the following statements about ASP & ASP.Net are correct?,
i. ASP is Interpreted where ASP.Net is compiled language.
ii. HTML statements can easily be inserted within functions in ASP where ASP.Net requires "Response.write"
iii. Functions in ASP.Net must appear in a <script runat=server> with Language declared.
iv. The function calls in ASP.Net require parentheses() appear after the function name.
I need help
2) ASP.Net allows switching between VBScript and JavaScript with in a page. Is this correct?
I need help
3) Controls in ASP and ASP.Net are Server side controls. Is this correct?
I need help
4) On which of the following events/methods during the life cycle of an ASP.Net application, the tasks like loading data to cache, initializing static data should be done for better results?
i. Application_Start
ii. Application_BeginRequest
iii. Application_EndRequest
iv. Application_Error
v. HttpApplication.Init
vi. Dispose
vii. Application_End
I need help
5) Any class that implements the IHttpHandler interface can act as a target for the incoming HTTP requests. Is this correct?
I need help
6) Which of the following events is registered by an HTTP module when ASP.Net runtime receives a new HTTP request?
i. AcquireRequestState
ii. AuthenticateRequest
iii. AuthorizeRequest
iv. BeginRequest
I need help
Conclusions...
1. ASP is interpreted language, ASP.Net is compiled language. One of the strengths of ASP was to easily drop functions into existing HTML pages without much re-coding. ASP.Net requires any HTML that appears within functions to be written to the screen using the response.write function. Have a look in to the below codes,
ASP:
<%
Function Hello()
For iDx=1 to 5
%>
<font size=<% =iDx %>>Hello</font>
<%
Next
End Function
Hello
%>
ASP.Net:
<%
Function Hello()
For iDx=1 to 5
Response.write("<font size="& iDx &"> Hello </font>")
Next
End Function
Hello()
%>
It's clear now
2. One of the large difference between ASP and ASP.Net is ASP.Net doesn't contain the capablity to have multiple languages on a single page. This means we cannot switch from VBScript to JavaScript and then back again. However we still have different languages on different pages within the same application.
It's clear now
3. No controls on Server side in ASP, all are server side controls in ASP.Net.
It's clear now
4. * The Application_Start method is called only once during the life cycle of an application. We can use this method to perform the startup tasks like loading data to cache, initializing static variables etc. However we should use this method only to initialize static values not instance data because it will be available only to the first instance of the HttpApplication class that is created.
* Application_BeginRequest and Application_EndRequest are to begin and end every requests (instances).
* Application_Error can be raised at any phase in the application life cycle.
* HttpApplication.Init called once for every instance of the HttpApplication class after all modules have been created.
* Dispose method os called before the application is destroyed. We can use this method to manually release any unmanaged resources.
* Application_End is called once per lifetime of the application before the application is unloaded.
It's clear now
5. Http handlers are the .NET components that implement the System.IHttpHandler interface. Any class that implements the IHttpHandler interface can act as a target for the incoming Http requests.
It's clear now
6. An Http module can register for the following events exposed by System.Web.HttpApplication object.
* AcquireRequestState event is raised when ASP.NET runtime is ready to acquire the Session state of the current HTTP request.
* AuthenticateRequest event is raised when ASP.NET runtime is ready to authenticate the identity of the user.
* AuthorizeRequest event is raised when ASP.NET runtime is ready to authorize the user for the resources that the user is trying to access.
* BeginRequest event is raised when ASP.NET runtime receives a new HTTP request.
It's clear now
Sunday, March 1, 2009
C# DOT NET - Objective Questions
Framework Fundamentals
1) On which of the following memory areas, the value type instances are stored?
i. stack
ii. heap
iii. queue
iv. dictionary
v.hashtable
a. None of the above
b. (i) only
c. (i) and (ii) only
d. (i) and (iii) only
e. All except (iv)
I need help
2) Which of the folowing built-in value types cannot afford the value -100?
i. sbyte
ii. byte
iii. int16
iv. int32
v. uint32
vi. single
vii. decimal
a. None of the above
b. (v) only
c. (i) and (v) only
d. (ii) and (v) only
e. (ii), (v) and (vii) only
f. None except (vi) and (vii)
I need help
3) What is the value range of date (DateTime) type in .NET?
a. 01-Jan-1900 00:00:00 to 31-Dec-2999 23:59:59
b. 01-Jan-1901 00:00:00 to 31-Dec-2099 23:59:59
c. 01-Jan-1901 00:00:00 to 31-Dec-2999 23:59:59
d. 01-Jan-0001 00:00:00 to 31-Dec-2999 23:59:59
e. 01-Jan-0001 00:00:00 to 31-Dec-9999 23:59:59
I need help
4) "In .NET Framework, all types are derived from System.Object."
Is this statement correct?
a. Yes
b. No
I need help
5) Which of the following are correct declaration of a Nullable boolean type (C#)?
i. <bool> Nullable var=null;
ii. (bool) Nullable var=null;
iii. Nullable (bool) var=null;
iv. Nullable <bool> var=null;
v. bool ? var=null;
I need help
6) Which of the following are value types?
i. Decimal
ii. String
iii. System.Drawing.Point
iv. Integer
a. None of the above
b. (iv) only.
c. All except (ii)
d. All except (ii) and (iii)
e. All the above
I need help
7) Assume a situation that we pass a value-type variable to a procedure. The procedure changes the varaiable, however when the procedure returns, the original value of the variable remains unchanged. What could be the reason?
a. The variable was not initialized before it was passed to the procedure.
b. Passing a value type into a procedure creates copy of the data.
c. The variable was redeclared within the procedure level.
d. The procedure handled the variable as a reference type.
e. None of the above
I need help
8) Assume a situation that we need to create a simple class or structure that contains only value types. We must create the class or structure so that it runs as efficiantly as possible. We must be able pass an instance of the class or struture to a procedure where the instance should not get modified. Which of the below is the right choice?>
a. A reference class.
b. A value class.
c. An reference structure.
d. A value struture.
e. None of the above
I need help
9) "Garbage collection recovers memory used by the area called heap"
Is this statement correct?
a. Yes
b. No
I need help
10) "What would be the output of the following code?"
class Numbers
{
public int val;
public Numbers(int _val)
{ val=_val; }
public override string ToString()
{ return val.ToString(); }
}
Numbers n1=new Numbers(0);
Numbers n2=n1;
n1.val+=1;
n2.val+=1;
Console.Writeline("n1={0}, n2={1}", n1.val,n2.val);
a. None of the above, Error.
b. n1=0, n2=0
c. n1=1, n2=1
d. n1=1, n2=2
e. n1=2, n2=2
f. None of the above, other results.
I need help
11) Which of the following are reference types?
i. Object ii. String iii. Text.StringBuilder iv. Array v. IO.Stream vi. Exception
a. None of the above.
b. (i) and (ii) only.
c. (ii), (iii) and (iv) only.
d. (i), (ii), (iii) and (v) only.
e. All except (vi).
f. All the above.
I need help
12) Howmany temporary strings would be created by the following code?
string str;
str="Hello,";
str+=" how";
str+=" are";
str+=" you?";
Console.Writeline(str);
a. No temporary strings
b. One
c. Two
d. Three
e. Four
I need help
13) What would be output of the following code?
try
{
StreamReader sr=new StreamReader("test.txt");
Console.WriteLine(sr.ReadToEnd());
}
catch(Exception ex)
{
Console.WriteLine(ex.message);
}
Finally
{
sr.Close();
}
a. Code will not get compiled.
b. The file contents will be displayed, however error at the end.
c. The file contents will be displayed without any error.
d. Try block will throw an exception.
I need help
14) Which one of the following properties helps to identify whether an object is value or reference type?
a. IsValueType
b. IsReferenceType
c. Type
d. Length
e. Size
I need help
15) What is the correct order for Catch clauses when handling different exception types?
a. Order from most general to most specific.
b. Order from most likely to least likely to occur.
c. Order from most specific to most general.
d. Order from least likely to most likely to occur.
e. None of the above.
I need help
16) When the StringBuilder class used instead of String class?
a. When building string from shorter strings.
b. When working with text data longer than 256 bytes.
c. When we need to perform search and replace within strings.
d. When a string is a value type.
e. None of the above.
I need help
17) Why should we close and dispose of resources in a Finally block instead of a Catch block?
a. It keeps us from having repeat the operation in each Catch block.
b. Finally block runs whether or not an execption occurs.
c. Exception will be thrown, if resources are not disposed in the Finally block.
d. We cannot dispose resources in a Catch block.
e. None of the above.
I need help
18) Which one of the following classes is the base class for user defined (derived) exceptions?
a. BaseException
b. SystemException
c. ApplicationException
d. UnauthorizedAccessException
e. Exception
I need help
19) Which of the following are valid built-in interfaces in DotNet?
i. IComparable
ii. IDisposable
iii. IConvertible
iv. IRemovable
v. ICloneable
vi. IEquatable
vii. IFormatable
a. None of the above
b. All except (iv), (v) and (vii)
c. All except (iv), (v)
d. All except (iv)
e. All the above
I need help
20) Interfaces drive a type from a base type
Is this statement correct?
a. Yes
b. No
I need help
21) Which of the following are built-in generic types?
i. Nullable
ii. Boolean
iii. EventHandler
iv. System.Drawing.Point
a. None of the above
b. (i) only
c. (i) and (ii) only
d. (i) and (iii) only
e. (iii) and (iv) only
f. All the above
I need help
22) What is the way for disposing generic objects?
a. Call the Object.Dispose method.
b. Implement IDisposable interface.
c. Derive the generic class from the IDisposable class.
d. Use constraints to require the generic type to implement the IDisposable interface.
e. None of the above
I need help
23) Assume a situation that we have implemented an event delegate from a class, but when we try to attach an event procedure we get a compiler error that there is no overload that matches the delegate. What happened?
a. The signature of the event procedure doesn't match that defined by the delegate.
b. The event procedure is declared as static, but it should be an instance member instead.
c. We mistyped the event procedure name when attaching it to the delegate.
d. The class was created in a different language.
I need help
Graphics
1) .NET Framework graphics includes tools to draw,
i. Lines ii. Shapes iii. Patterns iv. Text
a. None of the above
b. (i) only
c. (i) and (ii) only
d. All except (iii)
e. All the above
I need help
2) Which of the following cannot be done using System.Drawing namespace?
i. Add circles, lines
ii. Create charts from scratch
iii. Edit, resize pictures
iv. Change the compression ratios of pictures
v. Crop, zoom pictures
vi. Add copyright logos, text to pictures
a. None of the above
b. None except (iv)
c. None except (iii), (iv)
d. (i), (ii) and (vi) only
e. (i) and (ii) only
I need help
3) Two coordinates in the structure Point from System.Drawing namespace specify which of the following of an object?
a. Top left corner
b. Top right corner
c. Bottom left corner
d. Bottom right corner
e. Center point of the object
I need help
4) To specify custom colors, which of the following Color methods used?
a. Color.rgb
b. Color.FromRgb
c. Color.FromArgb
d. Color.FromColor
e. No method under Color class used for custom colors
I need help
5) Which of the following methods would result the Pie as shown below?
Pen p = new Pen(Color.Red, 5);
i. g.DrawPie(p, 10, 10, 100, 100, 180, 90);
ii. g.DrawPie(p, 10, 10, 100, 100, -180, 90);
iii. g.DrawPie(p, 10, 10, 100, 100, 0, 90);
iv. g.DrawPie(p, 10, 10, 100, 100, 360, 90);
v. g.DrawPie(p, 10, 10, 100, 100, 180, -90);
vi. g.DrawPie(p, 10, 10, 100, 100, -180, -90);
a. (i) only
b. (i) and (ii) only
c. (iii) and (iv) only
d. All except (iii) and (iv)
e. All the above
I need help
6) Which of the following methods of Graphics can be used to draw a square?
i. DrawLine
ii. DrawLines
iii. DrawEllipse
iv. DrawIcon
v. DrawPie
vi. DrawPolygon
vii. DrawRectangle
a. (vii) only
b. (vi) and (vii) only
c. (i) only
d. All except (iii), (iv) and (v)
e. All the above
I need help
7) Which of the following methods of Graphics can be used to draw a triangle with a solid color?
i. DrawLines
ii. DrawRectangle
iii. DrawPolygon
iv. DrawEllipse
v. FillRectangle
vi. FillPolygon
vii. FillEllipse
a. (iii) only
b. (vi) only
c. (v) and (vi) only
d. All except (i), (iv) and (vii)
e. All except (iv) and (vii)
I need help
8) Which of the following are invalid DashStyle properties?
i. Dash
ii. DashDot
iii. DashDotDot
iv. Dot
v. Solid
a. (iii) only
b. (iii) and (v) only
c. All except (i) and (iv)
d. None of the above
e. All the above
I need help
9) Which of the following are valid properties in LineCap enumeration?
i. ArrowAnchor
ii. DiamondAnchor
iii. SquareAnchor
iv. Trinagle
v. Flat
vi. Round
vii. TriangleAnchor
a. (i), (ii), (iii) and (vii) only
b. (iv), (v) and (vi) only
c. All except (vii)
d. All except (iv), (v) and (vi)
e. All the above.
I need help
10) Which of the following are invalid Brush classes under System.Drawing namespace?
i. HatchBrush
ii. LinearGradientBrush
iii. PathGradientBrush
iv. SolidBrush
v. TextureBrush
a. (ii) and (iii) only
b. (i), (ii) and (iii) only
c. (iv) and (v) only
d. None of the above
e. All the above
I need help
11) Which of the following classes under System.Drawing are cannot be inherited further?
i. Pen
ii. Region
iii. StringFormat
iv. SystemIcons
v. Brush
vi. Font
a. (v) only
b. (ii) and (v) only
c. All except (v)
d. All except (i) and (v)
e. All the above.
I need help
12) Which of the following classes under System.Drawing are mandatory to create a filled square?
i. Graphics
ii. Bitmap
iii. Icon
iv. Pen
v. Font
vi. Brush
vii. Image
a. (i) and (iv) only
b. (i) and (vi) only
c. (iv) and (vi) only
d. (i), (iv) and (vi) only
e. All except (iii) and (vii)
I need help
13) Which one of the following is the most efficient brush class to create a solid rectangle that is blue at top and fades to white towards to the bottom?
a. HatchBrush
b. LinearGradientBrush
c. PathGradientBrush
d. SolidBrush
e. TextureBrush
I need help
14) What would be the most exact result of the following code?
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 15);
p.StartCap = LineCap.Flat;
p.EndCap = LineCap.ArrowAnchor;
g.DrawLine(p, 50, 50, 50, 250);
a. A red colored flat down line
b. An red colored arrow points up
c. An red colored arrow points down
d. A red colored line goes downwards with a curve at the end
e. Syntax error
I need help
15) System.Drawing.Bitmap class which inherits Image class can be used to work with animated images (Yes/No)
a. Yes
b. No
I need help
16) Which of the following can be used to create a Bitmap?
i. Existing image
ii. Existing file
iii. Stream
iv. A blank bitmap of specified width and height
a. (i) and (iii) only
b. (iv) only
c. (i), (ii) and (iv) only
d. All except (ii)
e. All the above
I need help
17) To load an image from file into a picture box, edit it and save back to file, we need a Bitmap class along with Graphics class. (Yes/No)
a. Yes
b. No
I need help
18) Which of the following classes under System.Drawing can be used to edit pictures?
i. Icon
ii. Image
iii. Bitmap
iv. Brush
v. Pen
vi. Graphics
a. (i) and (ii) only
b. (ii) and (iii) only
c. (ii) and (iv) only
d. (ii), (iii) and (vi) only
e. (ii), (iv) and (vi) only
I need help
19) Which of the following classes can be used to load an image (.jpg) from an existing file into form?
i. System.Drawing.Image
ii. System.Drawing.Bitmap
iii. System.Drawing.Imaging.Metafile
iv. System.Windows.Forms.PictureBox
a. (ii) only
b. (i) and (ii) only
c. All except (iii)
d. None of the above
e. All the above
I need help
20) Which of the following image format would be most efficient to be opened in variety of applications?
a. ImageFormat.Bmp
b. ImageFormat.Gif
c. ImageFormat.Jpeg
d. ImageFormat.Png
I need help
21) Which of the image format would be fine to save a chart that could be opened in many applications?
a. ImageFormat.Bmp
b. ImageFormat.Gif
c. ImageFormat.Jpeg
d. ImageFormat.Png
I need help
22) Howmany different constructors the Font class supports?
a. 10
b. 13
c. 17
d. 24
I need help
23) Which of the following statements are correct in using FontConvertor class?
i. FontConvertor class can be used to read font type from a string.
ii. Casting is mandatory when reading a font type from string and assign to a Font object.
iii. It’s most reliable since exception handling can easily be done.
iv. FontConvertor cannot be used with unformatted strings due to Compiler errors.
v. FontConvertor class cannot be used with certain font families
a. (i) only
b. (i) and (ii) only
c. (i) and (iii) only
d. (i), (iii) and (v) only
e. All except (iv)
I need help
24) Graphics.DrawString helps to add text to Images and Bitmaps. Correct?
a. Yes
b. No
I need help
25) Which of the following members of StringFormat class aligns text at horizontally right?
a. StringAlignment.Right
b. StringAlignment.Near
c. StringRightAlignment
d. SrtringAlignment.Far
e. StringFarAligment
I need help
26) Which of following StringTrimming enumeration helps the text is trimmed to the nearest word and an ellipse is inserted at the end of a trimmed line.
a. EllipsisPath
b. EllipsisWord
c. EllipsisCharacter
d. Word
e. None of the above
I need help
27) Which of the following StringFormatFlags enumeration allows to display text from right to left?
a. DirectionVertical
b. DisplayFormatControl
c. FitBlackBox
d. NoFontFallBack
e. None of the above
I need help
28) Which of the following are mandatory to add a copyright text an image from local drive?
i. Bitmap which loads the image
ii. Graphics to be loaded with the image from Bitmap
iii. Font
iv. Brush
v. A string
vi. DrawString method
a. (i), (iii) and (vi) only
b. (i), (iii), (v) and (vi) only
c. (ii), (iv) and (vi)
d. All except (iv)
e. All the above
f. All the above, however still need more
I need help
29) Which of the following steps for adding text to an image?
a. i. Create a Graphics object ii. A String object iii.Call String.Draw
b. i. Create a Graphics object ii. A Font object iii. Brush object iv. Call Graphics.DrawString
c. i. Create a Graphics object ii. A Font object iii. Pen object iv. Call Graphics.DrawString
d. i. Create a Bitmap object ii. A Font object iii. Brush object iv. Call Bitmap.DrawString
I need help
30) Which of the following is a class would you need to create an instance of to specify that a string should be centered when drawn?
a. StringFormat
b. StringAlignment
c. FormatFlags
d. LineAlignment
e. None of the above
I need help
31) Which of the following commands would cause a string to be flush left?
a. StringFormat.LineAlignment=Near
b. StringFormat.LineAlignment=Far
c. StringFormat.Alignment=Near
d. StringFormat.Alignment=Far
e. None of the above
I need help
Conclusions here
Threading
1) What would be the outcome of the following code?
static void SomeWork()
{
Console.WriteLine("Hello, I am Thread “+
+Thread.CurrentThread.ManagedThreadId);
}
ThreadStart operation = new ThreadStart(SomeWork);
Thread[] theThreads = new Thread[5];
for (int x = 1; x <= 5; x++)
{
theThreads[x] = new Thread(operation);
theThreads[x].Start();
}
a. Compiler error due to lack of resources to start the Threads.
b. Hello, I am Thread 11
Hello, I am Thread 12
Hello, I am Thread 13
Hello, I am Thread 14
c. Hello, I am Thread 11
Hello, I am Thread 12
Hello, I am Thread 13
Hello, I am Thread 14
And a runtime error
d. Hello, I am Thread 11
Hello, I am Thread 12
Hello, I am Thread 13
Hello, I am Thread 14
Hello, I am Thread 15
e. No Thread would have got started and resulted a run time error
I need help
2) Which of the following values are invalid in ThreadPriority enumeration?
i. Highest
ii. AboveNormal
iii. Normal
iv. BelowNormal
v. Lowest
a. All of the above
b. (ii) and (iv) only
c. (ii), (iii) and (iv) only
d. All except (iv)
e. None of the above
I need help
3) Which of the following statements are valid in order to starting Threads?
i. Thread start delegate will accept only void methods.
ii. Thread start delegate will accept only static methods.
iii. Thread start delegate will accept only methods without parameters.
iv. Thread start delegate is used to start the execution of Threads.
v. Thread start delegate is used to create reference to a method which will run in a Thread.
a. None of the above
b. (i) only
c. (i) and (ii) only
d. (i), (ii) and (v) only
e. (i), (iii) and (iv) only
I need help
4) Which one of the following methods is used to stop a running thread?
a. Thread.Abort
b. Thread.Stop
c. Thread.Suspend
d. Thread.Join
e. None of the above
I need help
5) Which of the following are doing nothing with starting Threads?
i. ThreadStart delegate
ii. ParameterizedThreadStart delegate
iii. SynchronizationContext class
iv. ExecutionContext class
a. None of the above
b. (ii) only
c. (iii) and (iv) only
d. All except (iii) only
e. All the above
I need help
6) Which of the following Thread class properties are Read-only?
i. Name
ii. Priority
iii. ThreadState
iv. ManagedThreadId
v. IsBackground
vi. IsThreadPoolThread
a. (iii) only
b. (iii), (v) only
c. (iii), (iv) and (vi) only
d. All except (ii)
e. All the above
I need help
7) The Thread class method Interrupt interrupts a Thread only when the Thread is in blocked state. (Yes/No)?
a. Yes
b. No
I need help
8) Which of the following statement is correct with BeginCriticalRegion and EndCriticalRegion methods?
a. This is used to make sure that the code to be executed within the region will not be aborted.
b. This is used only to notify the host that the code to be executed within the region cannot be aborted safely.
I need help
9) Is the following statement correct (Yes/No)?
“SpinWait method blocks the current Thread for certain number of iterations, however it allows execution of other threads”
a. Yes
b. No
I need help
10) Which of the following ThreadState enumerations are invalid?
i. Aborted
ii. AbortRequested
iii. AbortReset
iv. Background
v. Stopped
vi. Unstarted
vii. Resumed
vi. Suspended
a. (iii), (iv) only
b. (vi), (vii) only
c. (iii), (vii) only
d. All except (i), (v), (vii) and (vi)
e. None of the above
I need help
11) What would be the possible output of the following code?
public class Counter
{
public static int count=0;
}
static void AddCount()
{
for(int i=1;i<=10000;i++)
Interlocked.Increment(ref Counter.count);
}
static void SubCount()
{
for (int i = 1; i <= 10000; i++)
Interlocked.Decrement(ref Counter.count);
}
ThreadStart add = new ThreadStart(AddCount);
ThreadStart sub = new ThreadStart(SubCount);
Thread[] threads = new Thread[4];
for (int i = 0; i < 4; i++)
{
if(i%2==0)
threads[i] = new Thread(add);
else
threads[i] = new Thread(sub);
threads[i].Start();
}
for (int i = 0; i < 4; i++)
{
threads[i].Join();
}
Console.WriteLine("Total : " + Counter.count);
a. -1
b. 0
c. 40000
d. 20000
e. None of the above
I need help
12) Which of the following are invalid Interlocked methods?
i. Add
ii. Decrement
iii. Increment
iv. Exchange
v. Read
vi. Remove
a. (i), (v) and (vi) only
b. (iv) and (vi) only
c. (vi) only
d. None except (iv)
e. None of the above
I need help
13) Consider that four different Threads execute the following function concurently (10 times each)
public void UpdateCount()
{
Interlocked.Increment(ref count);
if (count % 2 == 0) Interlocked.Increment(ref evencount);
}
Assume the intial values of count and evencount are 0. Secondly the execution is happening in a mutiprocessor machine. What would be the possible outcome after all Threads are completed?
i. count=0, evencount=0
ii. count=40, evencount=0
iii. count=40, evencount=18
iv. count=40, evencount=20
v. count=0, eventcount=20
vi. count=40, evencount=22
I need help
14) Which one of the following Monitor Methods is invalid?
a. Enter
b. Exit
c. TryEnter
d. TryExit
e. Wait
I need help
15) Is the following statement correct (Yes/No)?
“The ReaderWriterLock class allows unlimited readers to access the data at same time, but only a single writer can get lock on the data”
a. Yes
b. No
I need help
16) Is the following statement correct (Yes/No)?
“AcquireReaderLock method in ReaderWriterLock class gets a reader lock within a specified time. However it will take 100 milliseconds as default time, if the time is not mentioned”
a. Yes
b. No
I need help
17) Which of the following object is used when a lock to be upgraded to writer and downgraded then?
a. AcquireWriterLock and ReleaseWriterLock
b. LockCookie
c. UpgradeToWriterLock and DowngradeFromWriterLock
d. Monitor
e. ReaderWriter
I need help
18) Which of the following are correct in opening a Mutex which already exists with the name Mutex1?
a. Mutex m = OpenExisting(“Mutex1”);
b. Mutex m = Mutex.OpenExisting(“Mutex1”);
c. Mutex m = Open(“Mutex1”);
d. Mutex m = Mutex.Open(“Mutex1”);
e. None of the above, because Mutexes cannot be reopened
I need help
19) Which of the following objects allow synchronization with Windows kernel objects?
i. Semaphore
ii. Mutex
iii. Monitor
iv. Event
a. (ii) only
b. (i) and (ii) only
c. All except (iii)
d. All except (iv)
e. All the above
I need help
20) Which of the following code snippet helps to release two slots available in Semaphore? Assume that ‘sem’ is the object of Semaphore class.
a. sem.Release(2);
b. Semaphore.Release(2, sem);
c. Release(2, sem, Semaphore);
d. Release(Semaphore, sem, 2);
e. None of the above, because slots in Semaphore cannot be released explicitly.
I need help
21) Which of the following statements are correct with Event class?
i. Event has two states, on and off.
ii. There are two types of events, auto reset and manual reset.
iii. EventWaitHandle class supports two methods, Set and Reset.
iv. When creating a EventWaitHandle object, we just need to specify the type of event needed (AutoResetEvent and ManualResetEvent)
a. (i) only
b. (ii) and (iii) only
c. (iii) and (iv) only
d. All except (iv)
e. All the above
I need help
22) Which pattern of the following FileStream method Read helps to execute methods asynchronously or support APM?
a. Read and End
b. BeginRead and EndRead
c. BeginRead and End
d. Read and EndRead
e. None of the above since File stream class does not support APM
I need help
23) Which of the following rendezvous model uses IsCompleted property to see whether the asynchronous call is completed?
a. Polling
b. Wait-Until-done
c. Callback
d. IAsyncResult
e. AsyncCallBack
I need help
24) Which one of the following ThreadPool methods helps in thread-starving situation?
a. QueueUserWorkItem
b. UnsafeQueueUserWorkItem
c. SetMaxThreads
d. SetMinThreads
e. RegisterWaitForSingleObject
I need help
25) Is the following statement correct (Yes/No)?
“ThreadPool limits the number of new threads to be created during the running of a process to two per second”
a. Yes
b. No
I need help
26) Which one of the following arguments is not required when RegisterWaitForSingleObject method called for ThreadPool?
a. WaitHandle object
b. Delegate points to a method that takes the thread state as parameter
c. An object to read the maximum available threads in the Pool
d. Boolean value to indicate whether timeout has been reached
e. None of the above required
I need help
27) Which of the following statements are valid in SynchronizationContex class?
i. SynchronizationContex class allows writing code without knowing the threading model of the particular application
ii. Send or Post method will be used to call the executable code
iii. Send method will block until the executing code completes until returning
iv. Post method queues up the request and return immediately
v. Send method takes more time than Post method to return the object on which we can get the return value
a. (i) and (ii) only
b. (i), (iii) and (iv) only
c. (i), (ii) and (iv) only
d. All except (v)
e. All the above
I need help
28) Which of the following methods of ThreadPool class are used to have the ThreadPool run some specified code on Threads?
i. RegisterWaitForSingleObject
ii. QueueUserWorkItem
iii. UnsafeRegisterWaitForSingleObject
iv. UnsafeQueueUserWorkItem
v. UnsafeQueueNativeOverlapped
a. (i) and (iii) only
b. (ii) and (iv) only
c. (ii), (iv) and (v) only
d. All except (v) only
e. All the above
I need help
29) Which one of the following options will temporarily stop a Timer from firing?
a. Call Dispose on the Timer
b. Call Timer.Change and set the time values to Timeout.Infinite
c. Let the Timer object go out of scope
d. Call Timer.Change and set the time values to zero
e. None of the above steps may help stopping a Timer temporarily
I need help
30) Assume that there is a server with three processors and a database with almost 1,00,000 users. An application which is used to take the list of users and send email is running on the server. We get complaint from server management that the application is running very slowly. Which of the following statements might be correct to the above situation?
i. The application is single threaded which may give slow performance
ii. The application might be using all three processors which may degrade the performance
iii. Any of the processors might be busy with doing other jobs
iv. The application might be using an improper query to fetch the results from database.
v. The application might be using a ThreadPool class to identify the number of threads used to run the application
a. (i) only
b. (i) and (ii) only
c. (i) and (iv) only
d. (ii) and (v) only
e. All except (iii)
I need help
Conclusions...
Framework Fundamentals
1. * Instances of value types are stored in an area of memory called the stack, where the runtime can create, read, update and remove them quickly with minimal overhead.
* Reference types store the address of their data (also known as a pointer) on stack. The actual data that the address refers to is stored in an area called heap.
* queue, dictionary, hashtable are collection types available on .NET not memory areas.
It's clear now
2. * sbyte (signed byte) values can store from -128 to 127 - 1 Byte.
* byte (unsigned byte) values can store from 0 to 255 - 1 Byte.
* int16 (short) values can store from -32768 to 32767 - 2 Bytes.
* int32 (int) values can store negative numbers - 4 Bytes
* uint32 (unsigned integer) values can store from 0 - 4 Bytes
* single (float) can store values from negative (-100.00) - 4 Bytes
* decimal also can store values from negative - 16 Bytes.
It's clear now
3. The non-numeric data type System.DateTime (date) in .NET uses 8 Bytes to store date values between Jan 01 0001 12:00:00 AM to Dec 31 9999 11:59:59 PM.
It's clear now
4. In .NET Framework, all types are derived from System.Object. That relationship helps establishing the common type system used throughout the Framework.
It's clear now
5. Nullable type is new in .NET 2.0. It is used to determine whether a value has been assigned or not.
Declaration,
Dim var As Nullable (Of Boolean) = Nothing (VB.Net)
Nullable <bool> var = null; (C#.Net)
bool ? var = null; (Shortcut notation only on C#.Net)
It's clear now
6. String is a reference type. System.Drawing.Point, Integer, Decimal are value types.
It's clear now
7. * Value types must be initialized before passing to procedures unless they are declared as Nullable.
* Procedure works just with the copy of the data when we pass a value-type by value, not with the original value of the variable.
* Redeclaring variable within the procedure scope will not affect the value of the varaible.
* If the variable would have been passed by reference, the original value would also been modified.
It's clear now
8. * We can pass a class by reference, however the procedure will modify it.
* We can pass a class by value, however passing structures by value will be more efficient.
* We can pass a structure by reference, however the procedure will modifiy it. Secondly passing classes by reference will be more efficient.
* Strutures passed by values will be more efficient, will not be modified by the procedure.
It's clear now
9. * The actual data of reference types are stored in heap. The runtime manages the memory used by the heap by Garbage collection. Garbage collection is a process which recovers memory periodically as needed by disposing of items that are no longer referred.
* Garbage collection can be manually triggered by a call to GC.Collect
It's clear now
10. Class is reference type. When we modify values in reference types, the actual values in heap will be modified. The 'val' in both the instances refers to a same value in Heap. So the 'val' in both the instances will have 2 at the end.
It's clear now
11. All are reference types.
It's clear now
12. The code will create four strings. The last string will store the final result and display. The remaining three will be temporary and will be disposed during garbage collection.
It's clear now
13. The Finally block runs after the Try and Catch blocks are have finished executing, whether or not an Exception was thrown. The Finally block cannot access the variables declared in Try block.
It's clear now
14. IsValueType of an object type helps to identify whether the object is a value type.
It's clear now
15. Having multiple exception classes allows us to respond differently to different types or errors. The runtime will execute only the first Catch block with a matching exception type, so order Catch blocks from most specific to the least specific.
It's clear now
16. * StringBuilder will be used when building dynamic strings. String class will create lot of temporary strings when creating dynamic string from shorter strings.
* Strings are limited to 32,767 bytes, not 256 bytes.
* Search and replace has to be done with standard String class for better performance.
* Strings are never value types, they are reference types.
It's clear now
17. * Code in Catch block is executed only when the particular Exception occurs.
* Finally block is executed whether or not an exception occurs.
* Finally blocks optional, not mandatory.
* We can ofcourse dispose resources in a Catch block. However the code will run only when the particular Exception occurs.
It's clear now
18. We can define our own exceptions when we need to describe an event in more detail than allowed by the standard exception classes by deriving from System.ApplicationException class.
It's clear now
19. The below are the commonly used interfaces,
* IComparable - Implemented by types whose values can be ordered. Eg, the numeric and string classes. This is required for sorting.
* IDisposable - Defines methods for manually disposing of an object. This interface is important for large objects that consume resources, or objects that lock access to resources such as datatbases.
* IConvertible - Enables a class to be converte3d to a base type such as Boolean, Byte etc.
* ICloneable - Supports copying an object.
* IEquatable - Allows to compare instances of a class for equality. Eg, after implemeting this interface, we could say - if (obj1==obj2)
* IFormattable - Enables us to convert the value of an object into a specially formatted string. This provides greater flexiblity than the base ToString method.
It's clear now
20. Interfaces define a contract between types, ensuring that a class implements specific members.
Inheritance derives a type from a base type, automatically implementing all members of the base class, while allowing the derived class to extend or override the existing functionality.
It's clear now
21. Nullable and EventHandler are generic types
Boolean is non-generic value type.
Drawing.Point is a struture, not generic type.
It's clear now
22. * Object class doesn't have the Dispose method.
* Implementing an interface doesn't enable generic types to use interface methods.
* Deriving the generic class from an interface doesn't enable generic types to use interface methods.
* If we use constraints to require types to implementa specific interface, we can call any methods used in the interface.
It's clear now
23. * Delegates define the signature (arguments and the return type) for the entry point.
* Event procedures can be static or instance members.
* If we mistyped the event procedure name, we would have received compiler error.
* Events work equally well, regardless of the language used.
It's clear now
Graphics
1. The .NET Framework includes tools that allow us to draw lines, shapes, patterns and text.
It's clear now
2. The .NET Framework includes the System.Drawing namespace to enable us to create graphics from scratch or modify existing images. With System.Drawing namespace, we can...
* Add circles, lines, and other shapes to user interface dynamically.
* Create charts from scratch.
* Edit and resize pictures.
* Change the compression ratios od pictures saved yo disk.
* Crop or zoom pictures.
* Add copyright logos or text to pictures.
It's clear now
3. Point is used to set the control's location. The Point structure is created by specifying the coordinates relative to the upper-left corner of the Form.
It's clear now
4. Custom colors can be specified by the static method Color.FromArgb. This method has several overloads, so we can specify the color using a single byte, by specifying the red, green, blue levels, or by using the information.
Example,
label1.BackColor=Color.FromArgb(255, 0, 0);
It's clear now
5. DrawPie method draws a pie shape defined by an ellipse specified by a coordinate pair, a width, a height and two radial lines. The coordinate pair specify the upper left corner of an imaginary rectangle that would form the Pie's boundaries. The two radial lines specify the radial position and the radius between the two lines. The radial position 180 and -180 do not make any difference. The radius between the two lines is 90 degree. So the options (i) and (ii) would result the pie shape.
It's clear now
6. DrawLine and DrawLines are used to draw lines which can be managed to draw a square. DrawPolygon and DrawRectangle can ofcourse be used to draw square. DrawEllipse can only be used to draw round shapes. DrawPie cannot be used to draw rectangles. DrawIcon is used to draw images represented by the specified icon at the specified coordinates.
It's clear now
7. Methods that start with 'fill' only can be used to draw shapes with filled colors. Filled triangle can be drawn using FillRectangle, FillPolygon methods. There is no such method like FillTriangle under System.Drawing namespace.
It's clear now
8. DashStyle property under Pen class can be specified with values Dash, DashDot, DashDotDot, Dot or Solid.
It's clear now
9. LineCap enumeration doesn't have anchor shape in Triangle. There is no such TriangleAnchor in LineCap enumeration.
It's clear now
10. HatchBrush, LinearGradientBrush and PathGradientBrush are coming under System.Drawing.Drawing2D namespace. Only SolidBrush and TextureBrush are available directly under Systen.Drawing namespace.
It's clear now
11. Brush class can be inherited further. Rest cannot be inherited.
It's clear now
12. Graphics and Brush classes must be enough to create filled shapes.
It's clear now
13. LinearGradientBrush and PathGradientBrush can be used to fill color that fades gradually to a secondcolor. However LinearGradientBrush is more efficient.
It's clear now
14. The line starts flat and end by anchor, so that it would be an arrow. As per the points configuration, the arrown will point down.
It's clear now
15. We can use two classes that inherit Image - System.Drawing.Bitmap for still images and System.Drawing.Imaging.Metafile for animated images.
It's clear now
16. Bitmap is the most commonly used class for working with new or existing images. The different constructors allow you to create a Bitmap from an existing image, file or stream, or to create a blank bitmap of a specified height and width.
It's clear now
17. To edit existing picture, load it into a Bitmap class, edit it using Graphics object, and then call the Bitmap.Save method.
It's clear now
18. Image or Bitmap class along with Graphics is used to edit pictures.
It's clear now
19. We can load image from file using Image constructor, then call Graphics.DrawImage to diaplay the picture into form.
The Bitmap class inherits from Image class and can be used in many places where the Image class is used.
It's clear now
20. .bmp format can be used to store photographs, however .jpg format will consume less space.
.gif format is not ideal for storing photographs.
.jpg format offers excellent quality and compression with almost universal support.
.png format is very efficient, however its not compatible uinersally as GIF and JPG.
It's clear now
21. .bmp format can be used to store charts, however .gif format will consume less space.
.gif format is right choice for saving charts.
.jpg format can be used for storing charts, however the results may not be claer as .gif images.
.png format is very efficient, however its not compatible uinersally as GIF and JPG.
It's clear now
22. The Font class offers 13 different constructors.
It's clear now
23. FontConvertor can be used to read the font type from a string with casting. There is no restriction with any font family and format strinngs. Exception hanlding is not that easy since compiler cannot validate the font names in strings.
It's clear now
24. Graphics.DrawString helps to add text to Images and Bitmaps.
It's clear now
25. SrtringAlignment.Far helps to align the text horizontally right.
It's clear now
26. EllipsisWord helps the text is trimmed to the nearest word and an ellipse is inserted at the end of a trimmed line.
It's clear now
27. The mentioned StringFormatFlags enumerations,
* DirectionVertical - Text is vertically aligned.
* DisplayFormatControl - Control characters such as the left-to-right mark are shown in the output with a representative glyph.
* FitBlackBox - Parts of characters are allowed to overhang the string's layout rectangle. By default, characters are repositioned to avoid any overhang.
* NoFontFallBack - FallBack to alternate fonts for characters not supported in the requested font is displayed. Any missing characters are displayed with the fonts-missing glyph, usually an open square.
It's clear now
28. See the following code,
if(saveDialog.ShowDialog()!=DialogResult.Cancel)
{
//Define the Bitmap, Graphics, Font, and Brush for copyright logo.
Bitmap bm=(Bitmap)chart.Image;
Graphics g=Graphics.FromImage(bm);
Font f=new Font("Arial", 10);
Brush b=new SolidBrush(Color.White);
//Add the copyright text
g.DrawString("Copyright 20009, RamsMedia", f, b, 5, 5);
//Save the image to the specified file in JPEG format.
bm.Save(saveDialog.FileName, ImageFormat.Jpeg);
}
It's clear now
29. * The string class doesn't have a Draw method.
* We can add text by calling Graphics.DrawString, which requires a Graphics object, a Font object, and a Brush object.
* Graphics.DrawString requires a Brush object, not a Pen object.
* The Bitmap class doesn't have a DrawString method.
It's clear now
30. * Create an instance of the StringFormat class, and pass it to Graphics.DrawString to control the alignment of a string.
* StringAlignment can be used when specifying the formatting of a string, however it is an enumeration and we cannot create an instance of it.
* FormatFlags can be used when specifying the formatting of a string, however its a property of StringFormat and we cannot create instance of it.
* LineAlignment can be used when specifying the formatting of a string, however its a property of StringFormat and we cannot create instance of it.
It's clear now
31. * StringFormat.LineAlignment=Near would cause the line to be drawn at the top of the bounding rectangle.
* StringFormat.LineAlignment=Far would cause the line to be drawn at the bottom of the bounding rectangle.
* StringFormat.Alignment=Near would cause the line to be drawn at the left of the bounding rectangle.
* StringFormat.Alignment=Far would cause the line to be drawn at the right of the bounding rectangle.
It's clear now
Threading
1. A function which prints the thread id is executed by different threads. The Thread array has size 5 (0 to 4). However the 'For' loop iterates from 1 to 5. So the loop will start the Threads for index 1 to 4, while executing the index 5, we will get runtime error.
It's clear now
2. The following are the valid ThreadPriority enumerations,
* Highest - The highest priority.
* AboveNormal - Higher priority than Normal.
* Normal - The default priority.
* BelowNormal - Lower than Normal.
* Lowest - The lowest priority.
Threads are scheduled based on this enumeration. In most cases, we will want to use the default. Deciding to use threads that have lower thread priority can cause the operation system to starve a thread more than you might expect, or if we use higher priorities, we can starve the system.
It's clear now
3. * ThreadStart delegate is used as reference to a method which will run in a thread, however cannot be used to start the execution of threads.
* ThreadStart delegate will accept onlt static methods and return nothing.
* ThreadStart delegate will not accept parameterized methods. ParameterizedThreadStart delegate will accept parameterized methods.
It's clear now
4. * Suspend will only pause a thread, not stop it.
* Resume does do nothing with stoping threads.
* Abort method tells the thread to stop by firing a ThreadAbortException.
* Join waits until the thread is complete. It doesn't stop a thread.
It's clear now
5. * The ThreadStart delegate allow parameterless methods to start threads.
* The ParameterizedThreadStart expects a method with single parameter.
* The SynchronizationContext class has nothing to do with starting a thread.
* The ExecutionContext class is not required when starting a thread.
It's clear now
6. The mentioned Thread class properties,
* Name - Gets or sets a name associated with the Thread.
* Priority - Gets or sets the priority of the Thread.
* ThreadState - Gets the ThreadState value for the thread.
* ManagedThreadId - Gets a number to identify the current thread. Not the same as the operating system's thread Id.
* IsBackground - Gets or sets whether the thread runs as a background thread.
* IsThreadPoolThread - Gets whether this thread is a thread in the thread pool.
It's clear now
7. The Thread class method 'Interrupt' raises a ThreadInterruptedException when a thread is in a blocked state (ThreadState.WaitSleepJoin). If the thread never blocks, the interruption never happens.
It's clear now
8. BeginCriticalRegion and EndCriticalRegion to notify the host that the code to be executed within the region cannot be aborted safely. However cannot make sure that the code to be executed within the region will not be aborted.
It's clear now
9. The thread method SpinWait blocks the current thread for a certain number of iterations. Doesn't relinquish execution to other threads.
It's clear now
10. The mentioned ThreadState enumerations,
* Aborted - The thread has stopped.
* AbortRequested - The thread has been requested to abort, but the abort is still pending and has not received the ThreadAbortException.
* AbortReset - Invalid.
* Background - The thread is running as a background thread.
* Stopped - The thread has stopped.
* Unstarted - The thread has been created, but the Thread.Start method has not been called.
* Resumed - Invalid.
* Suspended - The thread has been suspendend. Supported for backward compatibility, but because Suspend/Resume should not be used, this state should not be used either.
It's clear now
11. The method 'Addcount' increments the 'count' one for 10000 times and the method 'SubCount' decrements one for 10000 times. A thread array, sized 4 execute the methods. Two threads execute 'AddCount' and the rest execute 'SubCount'. So the result is, Value of Add count (10000+10000) + Value of sub count (-10000-10000) = 0.
It's clear now
12. Interlocked class to perform the incrementing operation in multi-threaded operations.
* Add - A static method, adds two integers as an atomic operation. Can be used to subtraction with negative values.
* Decrement - A static method, subtracts one from a value as an atomic operation.
* Exchange - A static method, Swaps two values as an atomic operation.
* Increment - A static method, adds one to a value as an atomic operation.
* Read - A static method, reads a 64-bit number as an atomic operation. Required for 32-bit systems because 64-bit numbers are represented as two pieces of information.
It's clear now
13. The code increments 'count' ten times, and 'evencount' maximum five times(only when the 'count' comes to even value). After the four threads complete their execution, the 'count' value will be 40 (4x10). The 'evencount' would be maximum 20 (4x5). However there might be changes to have 'evencount' less than 20, not loo low.
It's clear now
14. The following static methods are available in Monitor class,
* Enter - Creates an exclusive lock on a specified object.
* Exit - Releases an exclusive lock on a specified object.
* TryEnter - Attempts to create an exclusive lock on a specified object, optionally supports a timeout value on acquiring the lock.
* Wait - Relases an exclusive lock, and blocks the current thread until it can re-acquire the lock.
It's clear now
15. The ReaderWriterLock allows multiple readers to access the data at the same time, but only a single writer can get a lock on the data. All readers must release their locks before a writer can get a lock on the data.
It's clear now
16. The AcquireReaderLock method in ReaderWriterLock class gets a reader lock within a specified time. If a lock cannot granted within the timeout period, an application exceptions is thrown. However the time in milliseconds has to be specified, no default time.
It's clear now
17. * AcquireWriterLock gets a writer lock within a specified time.
* ReleaseWriteLock frees a writer lock.
* UpgradeToWriterLock upgrades a reader lock to a writer lock.
* Monitor class is used to perform the synchronization.
* The UpgradeToWriterLock method returns a LockCookie is a structure that the ReaderWriterLock uses to allow the writer lock to be downgraded when we are done writing to the locked data.
It's clear now
18. In most cases, we will want to create the Mutex with a well-known name so that we can get the Mutex across AppDomain and/or process boundaries. If we create it with a name, we can use the Mutex's static OpenExisting method to get a Mutex that has already been created. The following code helps for this,
<The Mutex Instance>=Mutex.OpenExisting("<The Existing Mutex Name>");
It's clear now
19. At the operation system level, there are three kernel objects - Mutex, Semaphore and Event whose job to allow us to perform thread synchronization.
It's clear now
20. The following code specifies how Semaphore releases the require number of slots,
<the Semaphore instance>.Release(<Number of slots>);
It's clear now
21. * Events are a type of kernel object that has two states, On and Off. These states allow threads across an application to wait until an event is signaled to do something specific.
* There are two types of events - auto reset and manual reset. When an auto reset signaled, the first object waiting for the event turns it back to a non-signaled state. A manual reset event allows all threads that are waiting for it to become unblocked until something manually resets the event to a non-signaled state.
* EventWaitHandle class supports two new methods that are specific to working with events - Set and Reset. These methods are used to switch the event On and Off.
* When creating a new WaitHandle object, we not only specify the signal state, but also the type of event needed.
It's clear now
22. The BeginRead method handles the data going into the asynchronous operation, EndRead handles returning data from the asyncronous opetaion.
There needs a way to do the asynchronous operation and know when or where to call the endXX methods. Rendezvous techniques help here.
It's clear now
23.* In Wait-Until-Done method, after some work performed, the code calls the EndRead method, and this will block the thread until the asynchronous call is done. We will not be using callback, unnecessary.
* In Polling method, the code will poll the AsyncResult to see wether it has completed. By calling the IsCompleted property on the IAsyncResult object returned by the BeginRead, we can continue to do work as necessary untill the operation is complete.
* The Callback model requires that we specify a method to callback on and include any state that we need in the callback method to complete the call.
It's clear now
24. There are two types of situations where we will want to change the thread poolthread limits: Thread starvation, and startup thread spead.
In a thread-starvation scenario, our application is using the thread pool but is being hampered because we have too many work items and we are reaching the maximum number of threads in the pool. To set high watermark of threads for our application, we can simply use the ThreadPool.SetMaxThreads
int threads;
int completionports;
ThreadPool.GetMaxThreads(out threads, out completionports);
ThreadPool.SetMaxThreads(threads+10, completionports+100);
It's clear now
25. The ThreadPool limits the number of new threads to be created during the running of a process to two per second. If our applications need more threads created faster, we can increase the size.
It's clear now
26. The RegisterWaitForSingleObject method takes the WaitHandle object, as well as a delegate the points to a method that takes an object (that represents the thread state specified in the method call), and a boolean value that indicates whether the timeout has been reached instead of the WaitHandle being signaled.
It's clear now
27.* To deal with different threading models, the .NET framework supports the SynchronizationContext class, which allows us to write code without knowing the threading model of the particular application.
* Calling Send will execute the code (perhaps on a separate thread), however will block until the executing code completes until returning.
* Calling Post method will execute the code, however it is more like fire-and-forget in that it queues up the request and returns immediately id possible.
* Depending on the particular threading model, both the Send and Post methods might not return immediately. If executing the code asynchronously is not supported (Like in the Windows Forms threading model), both methods will run the code and return after the execution.
* The Send and Post methods do not return any sort of object on which we can wait on or get a return value.
* The SyncronizationContext class is usefull if you need to execute some arbitrary code but not act on the results on that code.
It's clear now
28.* RegisterWaitForSingleObject and UnsafeRegisterWaitForSingleObject are used to wait for WaitHandles to be signaled.
* QueueUserWorkItem and UnsafeQueueUserWorkItem are used to have a pool thread run code.
* UnsafeQueueNativeOverlapped is used to queue asynchronous File I/O completion ports, using the Overlapped and NativeOverlapped structures.
It's clear now
29.* Disposing the Timer will stop the timer and we cannot restart it.
* Using Timer.Change and setting the Timeout.Infinite will stop the Timer temporarily.
*
Allowing the Timer object to go out of scope will not stop the Timer from firing until garbage is collected, which could be anywhere from immediately to a long time down the road.
* Setting the timeout to zero will cause the time to continue as often as possible, the exact opposite of the requested result.
It's clear now
30. * The application might be single threaded, so only the main thread is running any code. This could be a reason for the slow performance.
* Making the application multithreaded to use equally well all the available CPUs will improve the performance.
* Using ThreadPool, which scales up the number of available threads based on the number of CPUs on a machine would improve the performance.
* Processors performing other tasks cannot degrade the performance of our application.
* Improper query to fetch the results can degrade the application performance.
It's clear now
Subscribe to:
Posts (Atom)