Click here to Skip to main content
15,905,504 members
Home / Discussions / C#
   

C#

 
QuestionExposing List<> outside class [modified] Pin
Jan Sommer26-Nov-08 2:10
Jan Sommer26-Nov-08 2:10 
AnswerRe: Exposing List<> outside class Pin
leppie26-Nov-08 2:20
leppie26-Nov-08 2:20 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 2:29
Jan Sommer26-Nov-08 2:29 
AnswerRe: Exposing List<> outside class Pin
leppie26-Nov-08 2:45
leppie26-Nov-08 2:45 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 3:00
Jan Sommer26-Nov-08 3:00 
GeneralRe: Exposing List<> outside class Pin
leppie26-Nov-08 3:20
leppie26-Nov-08 3:20 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 3:45
Jan Sommer26-Nov-08 3:45 
AnswerRe: Exposing List<> outside class Pin
Thomas Weller26-Nov-08 3:24
Thomas Weller26-Nov-08 3:24 
GeneralRe: Exposing List<> outside class Pin
Alan Balkany26-Nov-08 3:56
Alan Balkany26-Nov-08 3:56 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 4:09
Jan Sommer26-Nov-08 4:09 
GeneralRe: Exposing List<> outside class Pin
Thomas Weller26-Nov-08 4:30
Thomas Weller26-Nov-08 4:30 
Questionimplement IDisposable issue Pin
George_George26-Nov-08 1:57
George_George26-Nov-08 1:57 
AnswerRe: implement IDisposable issue Pin
leppie26-Nov-08 2:02
leppie26-Nov-08 2:02 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 2:08
George_George26-Nov-08 2:08 
GeneralRe: implement IDisposable issue Pin
leppie26-Nov-08 2:18
leppie26-Nov-08 2:18 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 2:25
George_George26-Nov-08 2:25 
GeneralRe: implement IDisposable issue Pin
leppie26-Nov-08 2:41
leppie26-Nov-08 2:41 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 3:16
George_George26-Nov-08 3:16 
GeneralRe: implement IDisposable issue Pin
leppie26-Nov-08 3:23
leppie26-Nov-08 3:23 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 3:31
George_George26-Nov-08 3:31 
AnswerRe: implement IDisposable issue Pin
Scott Dorman26-Nov-08 16:18
professionalScott Dorman26-Nov-08 16:18 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 20:58
George_George26-Nov-08 20:58 
Thanks Scott,

1.

"If so, then you generally don't need to do this" -- confused. Do you mean there is no need to call Dispose method in finalizer? If so, I disagree and in MSDN Dispose pattern, in finalizer dispose method is called with false value parameter.

2.

You mentioned "Normally static classes do not hold any internal state and would not actually need to do any object disposal of their own." -- confused. It is common to have a static class hold a member variable which pointed to disposable object instance, like stream. In your points, there is no need to dispose the wrapped disposable object instance?

3.

In my situation, the initialize method has to be static. Smile | :)

I have fixed some issues you mentioned and posted my new code below. Could you help to review whether my code is correct? Any potential issues?

class Logger : IDisposable
{
        private static bool disposed = false;
        private static StreamWriter  logStream;

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        ~Logger()
        {
            Dispose(false);
        }

        private static void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (false == disposed)
            {
                // If disposing equals true, dispose all managed 
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    LogStream.Dispose();
                    LogStream = null;
                }
            }
            disposed = true;
        }

        public static void Uninitialize()
        {
            Dispose(true);
            GC.SuppressFinalize(l ogStream);
        }
}


regards,
George
GeneralRe: implement IDisposable issue Pin
Scott Dorman27-Nov-08 2:49
professionalScott Dorman27-Nov-08 2:49 
QuestionHow edit my URL on button click Pin
Exelioindia26-Nov-08 1:48
Exelioindia26-Nov-08 1:48 
AnswerRe: How edit my URL on button click Pin
Simon P Stevens26-Nov-08 1:56
Simon P Stevens26-Nov-08 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.