Re: Class Library Design Problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I do have this working somewhat now. I have a singleton for my Logging
Class and I am creating one instance of my LoggingForm in the default
constructor of my Logging Class (Again Singleton designed). I might be able
to move the constructor code to my property...

Public Class Logging

Public Event LogMessageBarClicked()

Public Event LogExitDisplayLoggingWindow()

Public Event LogErrorOccurred(ByVal outEx As Exception) #End Region



Private m_instance As Logging

Private WithEvents m_formInstance As frmLogDisplay

Private m_LogToFile As Boolean



'Default constructor declared to facilitate singleton class model

Public Sub New()

Try

If m_formInstance Is Nothing Then

m_formInstance = New frmLogDisplay()

End If

Catch ex As Exception

'Exception logic here...

End Try

End Sub



Public ReadOnly Property Instance() As Logging

Get

Try

If m_instance Is Nothing Then

SyncLock GetType(Logging)

If m_instance Is Nothing Then

m_instance = New Logging

End If

End SyncLock

End If

Return m_instance

Catch ex As Exception

'EH code here.

End Try

End Get

End Property

..

..

..

'Rest of Class omitted...

End Class



From my LoggingForm I send an event back to my Logging Class with re-raise
it to the calling application. One thing I was trying to eliminate was the
events from the Form to the Logging Class. I have to look at how I was
creating the class objects before. I think I was using one variable for all
three instances so that may have been part of my problem. I'll post if I
have time when I figure out the problem with multiple forms. I don't have
that test code any longer and will have to back track.

Thanks of all your help! JerryM


.



Relevant Pages

  • Re: Using form controls from other classes.
    ... button on Form when C catches the exception. ... handler because I add the handler after creating the objects. ... If an exception is thrown and caught during initialization (whether part of construction or separate), and the fact of that exception is important to the clients of class C, why is that fact not exposed via a property? ... My Form contains the handlers for all events including logging. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: .NET Runtime 2.0 Error - I need more details...
    ... I just wanted to clarify one thing, the event logging that I'm talking ... For console appications however, the clr will ... so if you can not use this event to handle the exception. ... ConsoleException.Program.Main), calling mscorwks!JIT_Throw ...
    (microsoft.public.dotnet.framework)
  • Logging vs. Exceptions
    ... like logging facility) heavily in a 'log and recover' like manner. ... Ruby however have a quite nice exception semantics and thus I am ... that it is vital that calling method: 'x' does not blow up the program ...
    (comp.lang.ruby)
  • Re: Logging components?
    ... to logging frequently occuring exceptions once for each type. ... The database is not available, ... a 'cant find database' exception. ... MadExcept and EurekaLog. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: .NET Runtime 2.0 Error - I need more details...
    ... We'll start coding all applications with event log exception ... default execption logging for the clr & non-asp.net exceptions. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.framework)