diff --git a/glib/Idle.cs b/glib/Idle.cs index 407969411..189b3a8b0 100644 --- a/glib/Idle.cs +++ b/glib/Idle.cs @@ -44,30 +44,6 @@ namespace GLib { proxy_handler = new IdleHandlerInternal (Handler); } - ~IdleProxy () - { - Dispose (false); - } - - public void Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - protected virtual void Dispose (bool disposing) - { - // Both branches remove our delegate from the - // managed list of handlers, but only - // Source.Remove will remove it from the - // unmanaged list also. - - if (disposing) - Remove (); - else - Source.Remove (ID); - } - public bool Handler () { try { diff --git a/glib/Source.cs b/glib/Source.cs index 0140d7402..2ab98e572 100644 --- a/glib/Source.cs +++ b/glib/Source.cs @@ -31,11 +31,35 @@ namespace GLib { // // Base class for IdleProxy and TimeoutProxy // - internal class SourceProxy { + internal class SourceProxy : IDisposable { internal Delegate real_handler; internal Delegate proxy_handler; internal uint ID; + ~SourceProxy () + { + Dispose (false); + } + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + // Both branches remove our delegate from the + // managed list of handlers, but only + // Source.Remove will remove it from the + // unmanaged list also. + + if (disposing) + Remove (); + else + Source.Remove (ID); + } + internal void Remove () { Source.RemoveSourceHandler (ID); diff --git a/glib/Timeout.cs b/glib/Timeout.cs index ceaf98e3a..2e68e068f 100644 --- a/glib/Timeout.cs +++ b/glib/Timeout.cs @@ -42,30 +42,6 @@ namespace GLib { proxy_handler = new TimeoutHandlerInternal (Handler); } - ~TimeoutProxy () - { - Dispose (false); - } - - public void Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - protected virtual void Dispose (bool disposing) - { - // Both branches remove our delegate from the - // managed list of handlers, but only - // Source.Remove will remove it from the - // unmanaged list also. - - if (disposing) - Remove (); - else - Source.Remove (ID); - } - public bool Handler () { try {