Author: nicko
Date: Sat Oct 29 10:51:27 2005
New Revision: 329455

URL: http://svn.apache.org/viewcvs?rev=329455&view=rev
Log:
Fix for LOG4NET-50 Process.StartTime hangs on some systems
Changed to store the time the library is loaded rather than looking up the 
start time for the current process.

Modified:
    logging/log4net/trunk/src/Util/SystemInfo.cs

Modified: logging/log4net/trunk/src/Util/SystemInfo.cs
URL: 
http://svn.apache.org/viewcvs/logging/log4net/trunk/src/Util/SystemInfo.cs?rev=329455&r1=329454&r2=329455&view=diff
==============================================================================
--- logging/log4net/trunk/src/Util/SystemInfo.cs (original)
+++ logging/log4net/trunk/src/Util/SystemInfo.cs Sat Oct 29 10:51:27 2005
@@ -302,49 +302,31 @@
                        }
                }
 
-               private static DateTime s_processStartTime = DateTime.MinValue;
+               private static DateTime s_processStartTime = DateTime.Now;
 
                /// <summary>
                /// Get the start time for the current process.
                /// </summary>
                /// <remarks>
                /// <para>
-               /// Tries to get the start time for the current process.
-               /// Failing that it returns the time of the first call to
-               /// this property.
+               /// This is the time at which the log4net library was loaded 
into the
+               /// AppDomain. Due to reports of a hang in the call to <see 
cref="System.Diagnostics.Process.StartTime"/>
+               /// this is not the start time for the current process.
+               /// </para>
+               /// <para>
+               /// The log4net library should be loaded by an application 
early during its
+               /// startup, therefore this start time should be a good 
approximation for
+               /// the actual start time.
                /// </para>
                /// <para>
                /// Note that AppDomains may be loaded and unloaded within the
-               /// same process without the process terminating and therefore
-               /// without the process start time being reset.
+               /// same process without the process terminating, however this 
start time
+               /// will be set per AppDomain.
                /// </para>
                /// </remarks>
                public static DateTime ProcessStartTime
                {
-                       get
-                       {
-                               if (s_processStartTime == DateTime.MinValue)
-                               {
-#if (NETCF || SSCLI)
-                                       // NETCF does not have the 
System.Diagnostics.Process class
-                                       // SSCLI does not support StartTime 
property in System.Diagnostics.Process
-
-                                       // Use the time of the first call as 
the start time
-                                       s_processStartTime = DateTime.Now;
-#else
-                                       try
-                                       {
-                                               s_processStartTime = 
System.Diagnostics.Process.GetCurrentProcess().StartTime;
-                                       }
-                                       catch
-                                       {
-                                               // Unable to get the start 
time, use now as the start time
-                                               s_processStartTime = 
DateTime.Now;
-                                       }
-#endif
-                               }
-                               return s_processStartTime;
-                       }
+                       get { return s_processStartTime; }
                }
 
                #endregion Public Static Properties


Reply via email to