The two basic concepts are use in eventing framework.These are:
1.Delegates
2.Events.
Delegates are just basicallly methods pointers they are use to hold the refrence of methods.When we call these delegates the methods subcribe to this delegate automatically execute.
Note : we can assign more than one method to the single delegate.
Now the main purpose of delegate is use in the event driven programming.
Events are use when we want want to execute certain block of code on certain event like on button click etc.
Below is the image that will more show the concept of delegates and events
Below are some links that will elaborate more about Delegates and events.
http://www.codeproject.com/Articles/11541/The-Simplest-C-Events-Example-Imaginable
http://www.akadia.com/services/dotnet_delegates_and_events.html
We modeled the concept of events in Microsoft Dynamics AX 2012 on .NET eventing concepts.
The following table lists the terms in Microsoft Dynamics AX 2012 related to events.
Now I will show the demo of implementation of the Delegates and Events in Microsoft Dynamics AX.
1.Delegates
2.Events.
Delegates and Events:
Delegates are just basicallly methods pointers they are use to hold the refrence of methods.When we call these delegates the methods subcribe to this delegate automatically execute.
Note : we can assign more than one method to the single delegate.
Now the main purpose of delegate is use in the event driven programming.
Events are use when we want want to execute certain block of code on certain event like on button click etc.
Below is the image that will more show the concept of delegates and events
Below are some links that will elaborate more about Delegates and events.
http://www.codeproject.com/Articles/11541/The-Simplest-C-Events-Example-Imaginable
http://www.akadia.com/services/dotnet_delegates_and_events.html
We modeled the concept of events in Microsoft Dynamics AX 2012 on .NET eventing concepts.
The following table lists the terms in Microsoft Dynamics AX 2012 related to events.
Now I will show the demo of implementation of the Delegates and Events in Microsoft Dynamics AX.
Delegates In Microsoft Dynamics AX:
Below are the following steps for creating Delegates and than calling them in microsoft dynamics AX 2012
First create a class and than right click on that class and than select new -> delegate as you can see in the below image.
Now your delegate is created successfully now add the parameters into it as you can see in the below image.
Now we need to subcribe a method to this delegate this is because when we call this delegate the subcribe method will automatically called.
Note:we can subcribe more than one methods to the single delegate.
For subcribing methods we first need to create our method.
As I have already created as you can see in the below image.
In the above method you can see that I am adding the two numbers that I have send in the parameter and than I am going to print it.
Note:All the methods that are subcribe to delegate should have the same parameters and return type as of delagate have.
Now I will subcribe this method to the delegate.
Now right click the delegate and than select the new event handler subcription as you can see in the below image.
Now we will subcribe our delegate to this event handler.
Just right click the event handler and select properties and than enter the
class name and its method name as you can see in the below image.
Now as you can see in the above image.I have subscribe the method 1 in to the delegate 1.
Now in the next step we will call this delegate.Now as you know that delegate can not be called outside the class so what I did is I make method called method3 and than inside that method I am going to call the delegate and than from job I will call the method3.
You can see the method3 in the below image.
Now I will create a job and than call this method as you can see in the image below.
Now I will show you the output in the below image.
This was all in the eventing framewoerk part 1.In the next part I will show you the detail about events in AX.
I hope you like this post
thanks Muhammad Zahid.
First create a class and than right click on that class and than select new -> delegate as you can see in the below image.
Now your delegate is created successfully now add the parameters into it as you can see in the below image.
Now we need to subcribe a method to this delegate this is because when we call this delegate the subcribe method will automatically called.
Note:we can subcribe more than one methods to the single delegate.
For subcribing methods we first need to create our method.
As I have already created as you can see in the below image.
In the above method you can see that I am adding the two numbers that I have send in the parameter and than I am going to print it.
Note:All the methods that are subcribe to delegate should have the same parameters and return type as of delagate have.
Now I will subcribe this method to the delegate.
Now right click the delegate and than select the new event handler subcription as you can see in the below image.
Now we will subcribe our delegate to this event handler.
Just right click the event handler and select properties and than enter the
class name and its method name as you can see in the below image.
Now as you can see in the above image.I have subscribe the method 1 in to the delegate 1.
Now in the next step we will call this delegate.Now as you know that delegate can not be called outside the class so what I did is I make method called method3 and than inside that method I am going to call the delegate and than from job I will call the method3.
You can see the method3 in the below image.
Now I will create a job and than call this method as you can see in the image below.
Now I will show you the output in the below image.
This was all in the eventing framewoerk part 1.In the next part I will show you the detail about events in AX.
I hope you like this post
thanks Muhammad Zahid.
No comments:
Post a Comment