Tuesday, February 18, 2014

Quick note on Microsoft.Net Thread.Start, Delegate.BeginInvoke, Control.BeginInvoke

Thread.Start
Starts a new OS thread to execute the delegate. When the delegate returns, the thread is destroyed. This is quite a heavy-weight operation (starting and destroying a thread) so you typically only do it if the method is going to be long-running.

Delegate.BeginInvoke
Delegate.BeginInvoke will call the delegate on a thread pool thread. Once the method returns, the thread is returned to the pool to be reused by another task. The advantage of this is that queuing a method to the thread pool is relatively light-weight because you don't have to spin up a whole new thread every time.

Control.BeginInvoke

Control.BeginInvoke executes the specified delegate asynchronously on the thread that the control's underlying handle was created on. It basically takes a delegate and runs it on the thread that created the control on which you called BeginInvoke. In other words Control.BeginInvoke invokes the method on the thread for the control. UI components are inherently single-threaded and every interaction with a UI control must be done on the thread that created it. Control.BeginInvoke is a handy way to do that.

Reference links:-

6 comments:

  1. The information which you have provided is very good. It is very useful who is looking for MSBI online training Bangalore

    ReplyDelete
  2. Nice work, your blog is concept-oriented, kindly share more blogs like this
    Dot NET Online Course Hyderabad

    ReplyDelete
  3. You made some decent points there. I looked on the net to learn more about the issue and found most people will go along with your views on this web site.

    ReplyDelete
  4. Howdy! I understand this is somewhat off-topic but I had to ask. Does managing a well-established website like yours require a lot of work? I'm brand new to blogging but I do write in my diary on a daily basis. I'd like to start a blog so I can easily share my own experience and thoughts online. Please let me know if you have any kind of suggestions or tips for new aspiring blog owners. Appreciate it!

    ReplyDelete
  5. I cant taking office on focusing long adequate to research; lots less write this rosy of article. Youve outdone your self as quickly as this cloth truely. it's miles one of the greatest contents. GameMaker Studio 2 Download

    ReplyDelete
  6. who desired to feature-on happening their understanding subsequent to ease. The style of writing is exquisite and plus the content material is summit-notch. thanks for that perception you provide the readers! AVG Driver Update License Key

    ReplyDelete