Click here to Skip to main content
15,887,343 members
Home / Discussions / C#
   

C#

 
AnswerRe: Do something every t seconds Pin
Rajesh R Subramanian28-May-09 19:26
professionalRajesh R Subramanian28-May-09 19:26 
AnswerRe: Do something every t seconds Pin
Christian Graus28-May-09 19:27
protectorChristian Graus28-May-09 19:27 
AnswerRe: Do something every t seconds Pin
Mirko198029-May-09 4:19
Mirko198029-May-09 4:19 
Questionreally wierd think Pin
funic28-May-09 14:36
funic28-May-09 14:36 
Questioncreate setup package Pin
sakis2428-May-09 10:50
sakis2428-May-09 10:50 
AnswerRe: create setup package Pin
EliottA28-May-09 11:45
EliottA28-May-09 11:45 
QuestionCleaning up members of a static array property on app exit [modified] Pin
DaveyM6928-May-09 10:42
professionalDaveyM6928-May-09 10:42 
AnswerRe: Cleaning up members of a static array property on app exit Pin
Kythen28-May-09 13:36
Kythen28-May-09 13:36 
This is a good example of where you should use the Dispose pattern. You can find a bit about the Dispose pattern at http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx[^] on MSDN.

Here's a bit of a template example of the class members I would add to implemented it in your case:

private object syncRoot = new object();
private bool isDisposed = false;

~Output()
{
    Dispose(false);
}

public override void Close()
{
    Dispose();
}

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

protected virtual void Dispose(bool disposing)
{
    //   I'm assuming your code needs to be thread safe, so place the clean up code inside a lock.
    lock(syncRoot)
    {
        if(!isDisposed)
        {
            if(disposing)
            {
                //  Clean up managed resources here.
            }
            
            //  Clean up unmanaged resources here
        }

        isDisposed = true;
    }
}


I would also consider having some separate class, like a MIDIDeviceManager to control the life cycle of our Output objects and provide system information like the GetNumberOfDevices() method. In my opinion it would be a bit cleaner than having it all in the Output class. It could also allow you to only create the Output device instances the user needs, rather than an array of all of them.
GeneralRe: Cleaning up members of a static array property on app exit [modified] Pin
DaveyM6929-May-09 10:36
professionalDaveyM6929-May-09 10:36 
QuestionExecuting Application After Installation (Using Windows Installer) Pin
BlitzPackage28-May-09 9:29
BlitzPackage28-May-09 9:29 
Generalhelp for run length encoding Pin
ali rezaiy28-May-09 8:56
ali rezaiy28-May-09 8:56 
GeneralRe: help for run length encoding Pin
harold aptroot28-May-09 10:59
harold aptroot28-May-09 10:59 
GeneralRe: help for run length encoding Pin
Alan Balkany28-May-09 11:06
Alan Balkany28-May-09 11:06 
QuestionWhat are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
ToddHileHoffer28-May-09 7:45
ToddHileHoffer28-May-09 7:45 
AnswerRe: What are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
PIEBALDconsult28-May-09 8:22
mvePIEBALDconsult28-May-09 8:22 
AnswerRe: What are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
Henry Minute28-May-09 8:43
Henry Minute28-May-09 8:43 
GeneralRe: What are your preferences for work with databases ADO.net 2.0 LINQ TO SQL or Entity Framework Pin
ScottM128-May-09 20:21
ScottM128-May-09 20:21 
QuestionDraggable WinForm w/ Docked Control Problem Pin
baehoo28-May-09 7:42
baehoo28-May-09 7:42 
QuestionUsing sortedlist or sorteddictionary Pin
michaelgr128-May-09 7:10
michaelgr128-May-09 7:10 
AnswerRe: Using sortedlist or sorteddictionary Pin
Ennis Ray Lynch, Jr.28-May-09 7:23
Ennis Ray Lynch, Jr.28-May-09 7:23 
GeneralRe: Using sortedlist or sorteddictionary Pin
michaelgr128-May-09 7:24
michaelgr128-May-09 7:24 
GeneralRe: Using sortedlist or sorteddictionary Pin
Ennis Ray Lynch, Jr.28-May-09 7:29
Ennis Ray Lynch, Jr.28-May-09 7:29 
GeneralRe: Using sortedlist or sorteddictionary Pin
DaveyM6928-May-09 7:31
professionalDaveyM6928-May-09 7:31 
AnswerRe: Using sortedlist or sorteddictionary Pin
Luc Pattyn28-May-09 7:29
sitebuilderLuc Pattyn28-May-09 7:29 
GeneralRe: Using sortedlist or sorteddictionary Pin
michaelgr128-May-09 7:35
michaelgr128-May-09 7:35 

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.