dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Threading/Time...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/Threading/Time...
Date: Fri, 01 Aug 2008 17:42:59 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnetlib
Changes by:     Klaus Treichel <ktreichel>      08/08/01 17:42:59

Modified files:
        .              : ChangeLog 
        runtime/System/Threading: Timer.cs 

Log message:
        Fix DisposeInternal to handle the notify object only if the function is
        invoked by one of the Dispose functions and not by the finalizer.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2535&r2=1.2536
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/Threading/Timer.cs?cvsroot=dotgnu-pnet&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2535
retrieving revision 1.2536
diff -u -b -r1.2535 -r1.2536
--- ChangeLog   15 Jul 2008 07:13:22 -0000      1.2535
+++ ChangeLog   1 Aug 2008 17:42:58 -0000       1.2536
@@ -1,3 +1,13 @@
+2008-08-01  Klaus Treichel  <address@hidden>
+
+       * runtime/System/Threading/Timer.cs (DisposeInternal): Add an additional
+       bool argument disposing to specify if the function is invoked by one
+       of the Dispose functions or the finalizer. Handle the notify object only
+       if the function is invoked by one of the Dispose functions.
+       Handle the case when the alarm is already collected.
+       (~Timer): Pass false as additional argument to DisposeInternal.
+       (Dispose): Pass true as additional argument to DisposeInternal.
+       
 2008-07-15  Heiko Weiss <address@hidden>
 
        * Xsharp/TopLevelWindow.cs (DispatchEvent): Fix a positioning problem 

Index: runtime/System/Threading/Timer.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Threading/Timer.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- runtime/System/Threading/Timer.cs   27 Nov 2007 13:08:04 -0000      1.11
+++ runtime/System/Threading/Timer.cs   1 Aug 2008 17:42:58 -0000       1.12
@@ -126,7 +126,7 @@
                //
                ~Timer()
                {
-                       DisposeInternal(null);
+                       DisposeInternal(null, false);
                }
 
                //
@@ -193,7 +193,7 @@
                //
                public void Dispose()
                {
-                       DisposeInternal(null);
+                       DisposeInternal(null, true);
                }
 
                //
@@ -204,14 +204,18 @@
                {
                        if (notifyObject == null)
                                throw new ArgumentNullException("notifyObject");
-                       return DisposeInternal(notifyObject);
+                       return DisposeInternal(notifyObject, true);
                }
 
                //
                // Internal version of "Dispose".
                //
-               private bool DisposeInternal(WaitHandle notifyObject)
+               private bool DisposeInternal(WaitHandle notifyObject, bool 
disposing)
                {
+                       if(disposing)
+                       {
+                               // Add the timer to the dispose list only if it 
is disposed
+                               // by the application.
                        lock (this)
                        {
                                if (this.disposed)
@@ -227,6 +231,20 @@
                                Timer.threadWakeup.Set();
                        }
                        GC.SuppressFinalize(this);
+                       }
+                       else
+                       {
+                               // disable the timer
+                               // Hopefully the GC sets the references of 
garbage collected
+                               // objects to null in circular references like 
the delegate
+                               // in the alarm here. So we have to check if 
the alarm is
+                               // not null here before disabling it.
+                               if(this.alarm != null)
+                               {
+                                       this.alarm.SetAlarm(AlarmClock.INFINITE,
+                                                                               
AlarmClock.INFINITE);
+                               }
+                       }
                        return true;
                }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]