The illustrious SyncStack

If you’ve ever worked with a Stack in .NET and needed it to be thread safe, you’ll be interested to note the way that it appears to have been implemented by MS.  An object of type Stack has a function called Synchronised() which returns another Stack typed object, but underneath the covers is actually returning a completely internal type called a SyncStack which has the original Stack as a property of it. The stupid thing is, this SyncStack also inherits from Stack so essentially calling Synchronised gets a wrapper stack (assumedly with it’s own store) and an internal stack (which was the one you wanted synchronised).  What perplexes me is why they didn’t just make SyncStack publicly available? I can’t create my own fresh Synced Stack I have to make a non-synchronised version of it first.

Can anyone explain this to me please???

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: