C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Application windows, menus & toolbars »

CallBacks


Posted Date: 25 Dec 2008    Resource Type: Code Snippets    Category: Application windows, menus & toolbars
Author: Deepika HaridasMember Level: Diamond    
Rating: 1 out of 5Points: 20



CallBacks Using Delegate performs action using a delegate, and also requires registration and unregistration for the call.


private void cmdDelegateCallback_Click(object sender, System.EventArgs e)
{
//This method calls into a method of a Class1 instance, which in turn
//calls back into the client via a delegate.
Class1 refClass1 = new Class1();

//Create an instance of a delegate to represent the callback method
Delegate1 d = new Delegate1(this.CallbackMethod);

//Register the client, passing a reference to the delegate instance
refClass1.RegisterDelegateForCallback(d);

//Call the method which will in turn call back into the client
refClass1.UseDelegateCallback();

//Unregister the client
refClass1.UnRegisterDelegateForCallback();
}



Class file includes

delegate void Delegate1();
public void RegisterDelegateForCallback(Delegate1 d)
{
del1 = d;
}

public void UnRegisterDelegateForCallback()
{
del1 = null;
}

public void UseDelegateCallback()
{
if (del1 != null)
{
del1.BeginInvoke(null, null);
}
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Callbacks  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Font
Previous Resource: Performance counters
Return to Discussion Resource Index
Post New Resource
Category: Application windows, menus & toolbars


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use