Skip to content

Dictionary<TKey, TValue> is not thread safe #47

@taspeotis

Description

@taspeotis

I was reading your code to see how Serilog.Sink.AppCenter was implemented and came across this.

The Dictionary<TKey, TValue> class is not thread safe.

Thread Safety

...
To allow the collection to be accessed by multiple threads for ... writing, you must implement your own synchronization.

It's not really necessary to render properties in parallel, at most there are like ... twenty of them? I think this code only works because there are so few properties anyway it's unlikely to hit the race condition where two threads Add to the dictionary at the same time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions