use System.ComponentModel class Test var _visited as bool def main is shared Test().run def run assert not _visited using c = Component() listen c.disposed, ref .componentDisposed assert _visited _visited = false using c = Component() listen c.disposed, ref _componentDisposed assert _visited def componentDisposed(sender as Object, args as EventArgs) _visited = true def _componentDisposed(sender as Object, args as EventArgs) _visited = true