How Thread-Safe is NLog?

后端 未结 6 1965
慢半拍i
慢半拍i 2020-12-02 23:23

Well,

I have waited for days before deciding to post this issue, as I was not sure how to state this, resutling into a long detailed post. However, I think it is re

6条回答
  •  无人及你
    2020-12-02 23:46

    I think you might not be using lock correctly. You are locking on objects which are passed into your method so I think this means that different threads might lock on different objects.

    Most people just add this to their class:

    private static readonly object Lock = new object();
    

    Then lock on that and be guaranteed it will always be the same object.

    I'm not sure this will fix your problem, but what you are doing now seams strange to me. Other people might disaggree.

提交回复
热议问题