Click here to Skip to main content
15,895,667 members
Home / Discussions / C#
   

C#

 
QuestionRemoving refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 20:03
N a v a n e e t h23-Oct-07 20:03 
AnswerRe: Removing refrences or objects ? Garbage collector Pin
Christian Graus23-Oct-07 20:10
protectorChristian Graus23-Oct-07 20:10 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 20:14
N a v a n e e t h23-Oct-07 20:14 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Christian Graus23-Oct-07 20:25
protectorChristian Graus23-Oct-07 20:25 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 20:31
N a v a n e e t h23-Oct-07 20:31 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 20:45
lmoelleb23-Oct-07 20:45 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 20:59
N a v a n e e t h23-Oct-07 20:59 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 21:17
lmoelleb23-Oct-07 21:17 
Sorry I wasn't clear enough. With "it" I was referring to "whatever code cleans up the object", not specifically the Dispose method. I can see this was not clear the way I wrote it.

To avoid confusing statements I'll just include the standard dispose pattern here.

From memory, typing streight into the editor - syntax errors to be expected, but the pattern should be more or less correct.

<br />
class Whatever : IDisposable<br />
{<br />
  ~Whatever<br />
  {<br />
    // this is NOT calling Dispose as per MSDN instructions,<br />
    // but an overload of Dispose that could<br />
    // as well have been named something else (naming it<br />
    // Dispose(bool) is that standard though, so it would be confusing<br />
    // to deviate from it).<br />
    Dispose(false); <br />
  }<br />
<br />
  public void Dispose()<br />
  {<br />
    Dispose(true);<br />
  }<br />
<br />
  private void Dispose(bool disposing)<br />
  {<br />
    // TODO: Release any unmanaged references here (so no matter if<br />
    // it is a Dispose or finalizer call.<br />
    if (disposing)<br />
    {<br />
      // This is only executed when Dispose is called, not when called<br />
      // though the finalizer.<br />
<br />
      // TODO: Dispose referenced managed objects here if any of them<br />
      // implements IDisposable. Never ever try to release them from<br />
      // the finalizer call - they might already have been released.<br />
<br />
      // Tell the Garbage Collector it no longer need to finalize this, if<br />
      // this isn't done, the object will end up being promoted a generation<br />
      // before being released.<br />
      GC.SuppressFinalize(this)<br />
    }<br />
  }<br />
}<br />

GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 21:21
N a v a n e e t h23-Oct-07 21:21 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 21:27
lmoelleb23-Oct-07 21:27 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 21:32
N a v a n e e t h23-Oct-07 21:32 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb23-Oct-07 22:45
lmoelleb23-Oct-07 22:45 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
N a v a n e e t h23-Oct-07 23:01
N a v a n e e t h23-Oct-07 23:01 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:18
professionalScott Dorman24-Oct-07 1:18 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:19
professionalScott Dorman24-Oct-07 1:19 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:36
professionalScott Dorman24-Oct-07 1:36 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
lmoelleb24-Oct-07 2:35
lmoelleb24-Oct-07 2:35 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 12:46
professionalScott Dorman24-Oct-07 12:46 
GeneralRe: Removing refrences or objects ? Garbage collector Pin
Scott Dorman24-Oct-07 1:22
professionalScott Dorman24-Oct-07 1:22 
Questionupdate from combobo to textbox Pin
kabutar23-Oct-07 19:54
kabutar23-Oct-07 19:54 
AnswerRe: update from combobo to textbox Pin
Christian Graus23-Oct-07 20:02
protectorChristian Graus23-Oct-07 20:02 
GeneralRe: update from combobo to textbox Pin
kabutar23-Oct-07 20:07
kabutar23-Oct-07 20:07 
Questioninsertion of nature of comment row. [modified] Pin
alok217123-Oct-07 19:43
alok217123-Oct-07 19:43 
AnswerRe: insertion of nature of comment row. Pin
Christian Graus23-Oct-07 19:51
protectorChristian Graus23-Oct-07 19:51 
AnswerRe: insertion of nature of comment row. Pin
N a v a n e e t h23-Oct-07 19:53
N a v a n e e t h23-Oct-07 19:53 

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.