Skip to content

Instantly share code, notes, and snippets.

@hmcclungiii
Created April 14, 2014 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmcclungiii/10624053 to your computer and use it in GitHub Desktop.
Save hmcclungiii/10624053 to your computer and use it in GitHub Desktop.
C# Event Pattern
namespace eventpattern {
public delegate void AllPropertiesDetailsParsedEventHandler(object sender, AllPropertiesDetailsParsedEventArgs e);
public class AllPropertiesDetailsParsedEventArgs : EventArgs
{
}
public partial class Controller
{
public event AllPropertiesDetailsParsedEventHandler AllPropertiesDetailsParsed;
protected internal virtual void OnAllPropertiesDetailsParsed(AllPropertiesDetailsParsedEventArgs e)
{
AllPropertiesDetailsParsed(this, e);
}
}
public partial class MainForm : Form
{
private Controller controller = null;
public MainForm()
{
InitializeComponent();
controller = new Controller();
this.controller.AllPropertiesDetailsParsed += new AllPropertiesDetailsParsedEventHandler(this.AllPropertiesDetailsParsed);
}
private void AllPropertiesDetailsParsed(object sender, AllPropertiesDetailsParsedEventArgs e)
{
// Take action here (custom code)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment