Friday, 30 September 2011

How to debug threads ?

"Debug\Windows\Treads" in Visual Studio gives an access to the threads debug window.This window is only seen when the program is running in debug mode

What are Suspend() and Resume() methods in threading?

                   Those are similar to Sleep and Interrupt. Suspend allows you to block a thread until another thread calls Thread.Resume(). The difference between Sleep() and Suspend() is that the latter does not immediately place a thread in the wait state. The thread does not suspend until the .NET runtime determines that it is in a safe place to suspend it. Sleep() will immediately place a thread in a wait state

How can we make a thread sleep for infinite period?

                    You can also place a thread into the sleep state for an indeterminate amount of time by calling Thread.Sleep (System.Threading.Timeout.Infinite). To interrupt this sleep you can call the Thread.Interrupt() method

What does Thread.Sleep() do in threading?


                  Thread’s execution can be paused by calling the Thread.Sleep method. This method takes an integer value in milliseconds that determines how long the thread should sleep. Example: Thread.CurrentThread.Sleep(2000).

How can you reference current thread of the method?

"Thread.CurrentThread" refers to the current thread running in the method."CurrentThread" is a public static property

What does AddressOf operator do in background?


            The AddressOf operator creates a delegate object to the BackgroundProcess method. A delegate within VB.NET is a type-safe, object-oriented function pointer. After the thread has been instantiated, you begin the execution of the code by calling the Start() method of the thread.