I have a class shown below. Server instance holds reference to listener instance. Listener holds reference to server instance through event delegate. Will this prevent GC from collecting server instance? If so, how to break this cycle? Should I implement IDisposable or override Finalize method or do something else?
public class Server
{
public Listener Listener { get; private set; }
public Server(Listener listener)
{
Listener = listener;
Listener.ClientChannelConnected += new EventHandler<ClientChannelConnectedArgs>(listener_ClientChannelConnected);
}
void listener_ClientChannelConnected(object sender, ClientChannelConnectedArgs e)
{
...
}
}