protected void Dispose(bool Disposing) { try { if (bDisposed) { return; } if (Disposing) { //Object is being disposed, not finalized. //It is safe to access other objects (other than the base object) only from inside this block. mTrace.Trace("Disposing: " + TraceID, trcOption.trcMemory); //If Not IsNothing(mBytes) Then mBytes.Dispose() : mBytes = Nothing //If Not IsNothing(mDates) Then mDates.Dispose() : mDates = Nothing //If Not IsNothing(mErrors) Then mErrors.Dispose() : mErrors = Nothing if ((mFieldEdits != null)) { mFieldEdits.Dispose(); mFieldEdits = null; } //If Not IsNothing(mFileSystem) Then mFileSystem.Dispose() : mFileSystem = Nothing if ((mRegistry != null)) { mRegistry.Dispose(); mRegistry = null; } //If Not IsNothing(mSecurity) Then mSecurity.Dispose() : mSecurity = Nothing //If Not IsNothing(mSystem) Then mSystem.Dispose() : mSystem = Nothing if ((mUI != null)) { mUI.Dispose(); mUI = null; } //If Not IsNothing(mWin32Error) Then mWin32Error.Dispose() : mWin32Error = Nothing //For Each iCallStack As clsCallStack In mCallStackCollection // mCallStackCollection.Remove(1) // iCallStack.Dispose() : iCallStack = Nothing //Next iCallStack //mCallStackCollection = null; //For Each iString As clsString In mStringCollection // mStringCollection.Remove(1) // iString.Dispose() : iString = Nothing //Next iString mStringCollection = null; mTrace.Dispose(); mTrace = null; //Must be last so the rest can be traced... //Console.WriteLine(String.Format("Exiting {0}.Dispose{1}{2}", TraceID, vbTab, MemoryStats(GC.GetTotalMemory(True), Process.GetCurrentProcess()))) } } finally { //MyBase.Dispose(Disposing) bDisposed = true; } }
public clsSupport(System.Reflection.Assembly objAssembly = null, string OverrideApplicationName = bpeNullString, string TracePath = bpeNullString, clsTrace.trcOption toTraceOptions = trcOption.trcNone, bool bTraceMode = false) : base() { const string EntryName = "New"; System.Diagnostics.Process enterProcess = null; //Try if ((TracePath == null)) { TracePath = bpeNullString; } string strAssembly = null; if ((objAssembly == null)) { strAssembly = "Nothing"; } else { strAssembly = "{" + objAssembly.GetType().ToString() + "}"; } string Arguments = string.Format("objAssembly:={0},OverrideApplicationName:=\"{1}\",TracePath:=\"{2}\",toTraceOptions:={3},TraceMode:={4}", new object[] { strAssembly, OverrideApplicationName, TracePath, toTraceOptions.ToString(), bTraceMode.ToString() }); mOverrideApplicationName = OverrideApplicationName; mThread = System.Threading.Thread.CurrentThread; mThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; mAssemblyInfo = new AssemblyInfo(objAssembly); mTraceID = mAssemblyInfo.Product + "." + mAssemblyInfo.Name + "." + ModuleName; mTrace = new clsTrace(this, TracePath, toTraceOptions, bTraceMode); //Must be first so we can trace the rest... mRegionalTimeFormat = DateTimeFormatInfo.CurrentInfo.LongTimePattern; //GetRegionalSetting(Win.WinNLS.LOCALE_STIMEFORMAT) //Changing from tt to AMPM screws up grid formatting relying on fmrShortDateTime... //If Right(strRegionalTimeFormat, 3) = " tt" Then strRegionalTimeFormat = Mid(strRegionalTimeFormat, 1, Len(strRegionalTimeFormat) - 2) + "AMPM" mShortDate = DateTimeFormatInfo.CurrentInfo.ShortDatePattern; //GetRegionalSetting(Win.WinNLS.LOCALE_SSHORTDATE) mLongDate = DateTimeFormatInfo.CurrentInfo.LongDatePattern; //GetRegionalSetting(Win.WinNLS.LOCALE_SLONGDATE) string strMessage = mTraceID + "." + EntryName + "(" + Arguments + ")"; if ((mTrace.TraceOptions & trcOption.trcMemory) == trcOption.trcMemory) { enterProcess = Process.GetCurrentProcess(); } mTrace.Trace(trcType.trcEnter, strMessage, trcOption.trcSupport); //mErrors = New clsErrors(Me) //'Force an allocation of a new clsError object for this thread... //Dim i As Integer = mErrors.LastError(Threading.Thread.CurrentThread.ManagedThreadId).Number //'Allocate a CallStack for this (main) thread... Others will be created as necessary in SetupNewThread()... //mCallStackCollection.Add(New clsCallStack(Me), CStr(Threading.Thread.CurrentThread.ManagedThreadId)) //'Allocate a String for this (main) thread... Others will be created as necessary in SetupNewThread()... //mStringCollection.Add(New clsString(Me), CStr(Threading.Thread.CurrentThread.ManagedThreadId)) //Do more stuff, if necessary... //Catch ex As Exception // If Not IsNothing(mErrors) Then mErrors.RaiseError(Threading.Thread.CurrentThread.ManagedThreadId, mTraceID, EntryName, ex, Nothing) Else Throw ex //End Try if ((mTrace != null)) { mTrace.Trace(trcType.trcExit, mTraceID + "." + EntryName, trcOption.trcSupport | trcOption.trcMemory, enterProcess); } enterProcess = null; mLogFile = string.Format("{0}\\{1}.log", this.ApplicationPath, this.ApplicationName); }