Is there a way to wrap an object up as a ConcurrentObject?

michael

I know how to utilize the ConcurrentDictionary<TKey, TValue> class by using a GetOrAdd() method very nicely. Is there a similar class for a single object instead? I'd rather not create a dictionary for a single object just to get concurrency.


Right now, I'm doing the following:

return _singledict.GetOrAdd(_sync, CreateSingleItem);
Servy

It sounds like you want to have some means of accessing an existing object if it has already been constructed, and constructing a new one if it hasn't been, with the appropriate tools in place to prevent the construction of multiple objects.

This is exactly what Lazy<T> exists for.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is there a way to wrap a jquery function to an object?

From Dev

Cleaner way to wrap up jquery functions

From Dev

What's the simplest way to wrap up an existing Windows with a Linux host?

From Dev

What is the proper way to wrap a JSON object in another object?

From Dev

IS there a way to wrap a Objective-C Object with a C++ Class

From Dev

Keep object the right way up on the surface of a planet

From Dev

How to wrap up multiple byte arrays in such a way that it can be serialized and used over RMI

From Dev

A way to Wrap LinearLayout

From Dev

easy way to check up series of consistency in rails model object

From Dev

Is there a way to bring up a dialog multiple times using the same object?

From Dev

Wrap an object into a derived class

From Dev

cython wrap struct as object

From Dev

Is this the correct way to wrap readFileSync in a Promise

From Java

Is there a more efficient way to wrap a float?

From Dev

best way to wrap opengl models

From Dev

Is there a way to word wrap the text in a button?

From Dev

Wrap array around SimpleXML object

From Dev

Node Streams, wrap array as object

From Dev

Wrap array around SimpleXML object

From Dev

How to wrap object in proxy for debugging?

From Dev

Sliding up Animation but wrap_content

From Dev

Word wrap up to two lines in a table cell

From Dev

I need to wrap up table row into div

From Dev

Wrap the Latin characters sequences up with the span tag

From Dev

Sliding up Animation but wrap_content

From Dev

Javascript: Namespace wrap up for normal function

From Dev

Iterate through an object recursively to find child, picking up parents, grandparents etc along the way

From Dev

With Django, what is the best practice way to add up a specific field on each object in a queryset?

From Dev

Can you put an if statement in a constructor in c++ to set up an object in a particular way?

Related Related

  1. 1

    Is there a way to wrap a jquery function to an object?

  2. 2

    Cleaner way to wrap up jquery functions

  3. 3

    What's the simplest way to wrap up an existing Windows with a Linux host?

  4. 4

    What is the proper way to wrap a JSON object in another object?

  5. 5

    IS there a way to wrap a Objective-C Object with a C++ Class

  6. 6

    Keep object the right way up on the surface of a planet

  7. 7

    How to wrap up multiple byte arrays in such a way that it can be serialized and used over RMI

  8. 8

    A way to Wrap LinearLayout

  9. 9

    easy way to check up series of consistency in rails model object

  10. 10

    Is there a way to bring up a dialog multiple times using the same object?

  11. 11

    Wrap an object into a derived class

  12. 12

    cython wrap struct as object

  13. 13

    Is this the correct way to wrap readFileSync in a Promise

  14. 14

    Is there a more efficient way to wrap a float?

  15. 15

    best way to wrap opengl models

  16. 16

    Is there a way to word wrap the text in a button?

  17. 17

    Wrap array around SimpleXML object

  18. 18

    Node Streams, wrap array as object

  19. 19

    Wrap array around SimpleXML object

  20. 20

    How to wrap object in proxy for debugging?

  21. 21

    Sliding up Animation but wrap_content

  22. 22

    Word wrap up to two lines in a table cell

  23. 23

    I need to wrap up table row into div

  24. 24

    Wrap the Latin characters sequences up with the span tag

  25. 25

    Sliding up Animation but wrap_content

  26. 26

    Javascript: Namespace wrap up for normal function

  27. 27

    Iterate through an object recursively to find child, picking up parents, grandparents etc along the way

  28. 28

    With Django, what is the best practice way to add up a specific field on each object in a queryset?

  29. 29

    Can you put an if statement in a constructor in c++ to set up an object in a particular way?

HotTag

Archive