Let's inspect the following scenario (translating events):
public void HookSpecificButton(SpecificButton specificButton, EventHandler eh)
{
specificButton.SpecificClick += (o, e) => eh(o, EventArgs.Empty);
}
The whole point of the code is to translate event from one type to another: I don't care about data passed by the specificButton through SpecificClick and I want to attach to this event regular EventHandler.
My question is the following. eh contains a reference to method of some object. If there's no other reference to that object, will the lambda be enough for that object to be kept alive? The chain is:
specificButton keeps alive an instance of EventHandler<SpecificData>, which keeps alive (lambda) which keeps alive (?) an instance of EventHandler, which keeps alive the final object.