Showing posts with label Delegates. Show all posts
Showing posts with label Delegates. Show all posts

Tuesday, April 3, 2012

Asynchronous method calling using events and delegates - CodeProject®

 Introduction to the article
In this article, we’ll elaborate how to call methods asynchronously. As we all know, delegates are used to call methods asynchronously, but here we’ll combine asynchronous function calling and the event handling concept for achieving Asynchronous Processing. To avoid confusion, let’s define what we are going to do in this example shortly.
  1. We’ll develop a Task class that contains an IterateFile() method and three events – StatusEvent, Complete, ProgressChanged. StatusEvent will keep track of the file status during file processing. The Complete event is raised when file processing completes. The ProgressChanged event is raised when the iteration completes.
  2. We’ll also develop the FileProcessing class that contains the Processing() method and StatusEvent. StatusEvent is raised when file processing status changes.
  3. We’ll have a Windows Form that displays all this information.


Asynchronous method calling using events and delegates - CodeProject®
Enhanced by Zemanta

Saturday, March 31, 2012

Asynchronous method calling using events and delegates - CodeProject®

Introduction to Article

In this article, we’ll elaborate how to call methods asynchronously. As we all know, delegates are used to call methods asynchronously, but here we’ll combine asynchronous function calling and the event handling concept for achieving Asynchronous Processing. To avoid confusion, let’s define what we are going to do in this example shortly.

We’ll develop a Task class that contains an IterateFile() method and three events – StatusEvent, Complete, ProgressChanged. StatusEvent will keep track of the file status during file processing. The Complete event is raised when file processing completes. The ProgressChanged event is raised when the iteration completes.
We’ll also develop the FileProcessing class that contains the Processing() method and StatusEvent. StatusEvent is raised when file processing status changes.
We’ll have a Windows Form that displays all this information.


Asynchronous method calling using events and delegates - CodeProject®

Wednesday, November 30, 2011

Delegates in C# - CodeProject

English: Logo for C Sharp (programming language)
Image via Wikipedia
Introduction to Article

Let’s play around with the main interrelated concepts of delegates in C#.
Today, in this article, we will dig out and play around by creating a simple delegate program and let’s see how better we can perform in this single program only. I mean, in this program, I will cover all stuff required for delegates from all the possible ways. So I will be covering simple delegate creation, multi-cast delegate, use of named methods, use of anonymous methods, use of lambda expression and finally a much better implementation about all of these and generic delegates as well.


Delegates in C# - CodeProject
Enhanced by Zemanta