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

C#

 
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 
Hello everyone,

I have a static class which wraps a file stream object. And I want to implement the Dispose pattern. I define an uninitialize method in the static class which call Dispose explicitly with parameter value true. Here is my code,

My questions are,

1. Normally there should be a destructor in a class which calls Dispose with parameter value false, but for a static class, there is no concept like destructor, how to implement calling Dispose with false parameter?

2. When the Dispose method without parameter will be called?

3. Is it correct to call GC.SuppressFinalize(this)? Since for a static class, there is no "this" object?

4. Correct to define disposed as static field?

5. Are there anything wrong with my code?

static private StreamWriter currentLogStream;

private static bool disposed = false;

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

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.
            currentLogStream.Dispose();
        }
    }
    disposed = true;
}

public static void Uninitialize()
{
    Dispose(true);
}


thanks in advance,
George
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 
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 
AnswerRe: How edit my URL on button click Pin
Dominic Goulet1-Dec-08 1:09
Dominic Goulet1-Dec-08 1:09 
QuestionExhange Server 2007 Webservice Pin
boiDev26-Nov-08 1:33
boiDev26-Nov-08 1:33 
Questioncopying files fast from 1 drive to other Pin
sumit703426-Nov-08 0:59
sumit703426-Nov-08 0:59 
AnswerRe: copying files fast from 1 drive to other Pin
Guffa26-Nov-08 1:14
Guffa26-Nov-08 1:14 

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.