For developers the quality of a program can be often express in the time used to finish the computation. With current multicore processor we have to move our thinking from a serial execution to a concurrent execution. Using delegates in an asynchronous way can force the CLR to allocate multiple threads to your computation.
In below code sample, you will see that I call one method multiple times. This method simply waits 5 seconds. Calling 6 times this method in a synchronous way makes the time to finish obvious: at least 30 seconds! Now using the BeginInvoke method from my delegate I can add multiple threads to these computations. On my machine the time to achieve this is now 9 seconds only!
Delegate can also be used to call method from different classes. I let you check at the documentation on Msdn.
Like this:
Like Loading...
Related
With the new TaskFactory class from .Net 4.0 it has become incredibly easy to manage dependencies between multiple tasks. In below code sample, the TaskFactory receive 6 tasks to execute. Additional logic is added as: - Task A will only be run when Task B and C are completed. -…
June 21, 2010
In “CSharp”
I had to made a scrollbar for a movieClip created by ActionScript. All that ended with a function: ScrollMc(MovieClip2Scroll, ScrollBarMc); It supports all movieClip (at least I hope, tell me if not) and you can have multiple scrollbar over multiple MC (multiple scrollbar for one MC also work). [kml_flashembed movie="http://www.metah.ch/blog/image/sampleScroll.swf"…
May 6, 2006
In “Experiment”
The incredible advantage that Desktop application have on web application is the connection with the local computer (other application, file system, computation, ...). Unfortunately the mix between AIR and desktop properties are not as far as Java or C. The most wanted functionalities are to launch native application through AIR…
February 5, 2008
In “ActionScript3”
A very good article to clear my doubts on sync and async method calling from delegate
Thanks Naseet.
through the main thread execution i created a delegate to invoke but at the time of closing i am getting exception objectdispose exception what should i do
Prassana, can you share your code?
good program but explanation is missing???
thanks… good one !!!
very good article.Thanks for sharing .Keep writing .All the Best .
Thank you Priya.
Nice article
You made my day Awesome !!! Thanks Ahmet
Thank you Karthik!