Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Created July 12, 2011 03:57
Show Gist options
  • Select an option

  • Save vasily-kirichenko/1077366 to your computer and use it in GitHub Desktop.

Select an option

Save vasily-kirichenko/1077366 to your computer and use it in GitHub Desktop.
Events
var worker = new Worker();
var anotherClass = new AnotherClass();
worker.WorkDone += anotherClass.WorkDone;
worker.DoWork();
class Worker
{
public event Action WorkDone;
public void DoWork()
{
//..
var workDoneCopy = WorkDone;
if (workDoneCopy != null)
workDoneCopy();
}
}
class AnotherClass
{
public void WorkDone()
{
//..
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment