[ 
https://issues.apache.org/jira/browse/AMQNET-50?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jim Gomes updated AMQNET-50:
----------------------------

    Parent:     (was: AMQNET-68)

> Disposable objects should follow standard disposable implementation pattern
> ---------------------------------------------------------------------------
>
>                 Key: AMQNET-50
>                 URL: https://issues.apache.org/jira/browse/AMQNET-50
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: ActiveMQ
>         Environment: Windows XP SP2, .NET 2.0
>            Reporter: Jim Gomes
>            Assignee: james strachan
>            Priority: Minor
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> Objects that implement the IDispose interface and have unmanaged resources 
> should use the dispose pattern that uses an internal method to dispose of the 
> objects and then turns off the finalizer call from the garbage collector.  
> This allows for safe and efficient disposable of unmanaged resources.
> The following objects implement the IDisposable interface and have 
> attachments to unmanaged resources.  
> ActiveMQ.Connection
> ActiveMQ.Session
> ActiveMQ.MessageProducer
> ActiveMQ.MessageConsumer
> The basic pattern is as follows:
> class Disposable : public IDispose
> {
>     private bool disposed = false;
>     ~Disposable()
>     {
>         Dispose(false);
>     }
>     public void Dispose()
>     {
>         Dispose(true);
>         GC.SuppressFinalize(this);
>     }
>     protected void Dispose(bool disposing)
>     {
>         if(disposed)
>         {
>             return;
>         }
>         if(disposing)
>         {
>             // Dispose managed code here
>         }
>         // Dispose unmanaged code here
>         disposed = true;
>     }
> }

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to