IDisposable and Thread Safety(www.blackwasp.co.uk)

submitted by rcashrcash(4149) 6 months, 21 days ago

IDisposable is a standard interface in the .NET framework. This article discusses the importance of using it in parallel or multithread programming.

3 comments |category: |Views: 29

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by dpetersondpeterson(4397) 6 months, 21 days ago 0

Locking is the correct solution here as we're talking about stuff far more advanced than something like a simple getter/setter. It's imperative that the disposable stuff only gets called from one thread at a time.

Reply

posted by vijaystvijayst(1311) 6 months, 21 days ago 0

I am always curious to know something about the IDispose interface. How does the compiler know that we have to implement a protected virtual Dispose(bool) method? Or make the class sealed?

Reply

posted by NoldorinNoldorin(829) 6 months, 20 days ago 0

This is a good point to highlight, but I do not believe it is the most efficient.

I personally use an Interlocked-based method to good effect here. There is really no need for something as "heavy" as locking here.

Reply

information Login or create an account to comment on this story