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