What is the difference between Calling a method by one of the three methods?

Go To StackoverFlow.com

1

What is the difference between Calling a method by one of the three methods ?

  1. via Creating a new thread
  2. Synchronous call through Invoke
  3. Asynchronous call through BeginInvoke and alternatively EndInvoke

I am assuming all the calls will be using a matching delegate under the hood.

2012-04-05 18:01
by rajibdotnet
What language are we talking about here? Can you edit your question with the BeginInvoke and EndInvoke code? Maybe that will be apparent to folks who know about that but it's not to me - Gray 2012-04-05 18:03
It looks like .NET - especially given the user's name and the question details.. - Reed Copsey 2012-04-05 18:06
@Gray looks like a .NET platform if there is BeginInvoke/EndInvoke and the fact that the OP's username has Dot NET in it - Kiril 2012-04-05 18:07
Ha! Didn't think to check the screen name @Lirik. Thanks - Gray 2012-04-05 18:09
Its C# languag - rajibdotnet 2012-04-05 19:38


1

(Assuming .NET given your user name...) These three options are different ways to use a delegate.

Creating a new thread doesn't specifically "call a method", but rather starts a new thread using a specified delegate as the method to run within the new thread. This will launch an entire new thread for you, and run your delegate within the separate thread.

Asynchronously calling the delegate via BeginInvoke/EndInvoke is similar, except that it will use the ThreadPool instead of creating a new thread.

Synchronously calling the delegate via Invoke will just call the delegate directly on the currently executing thread. This effectively just calls the method being referenced by the delegate.

2012-04-05 18:06
by Reed Copsey
So can I say....running a delegate in separate thread and asynchronous calling are both background process - rajibdotnet 2012-04-06 14:16
Ads