How to effectively log asynchronously?

前端 未结 10 1106
无人及你
无人及你 2020-12-07 07:28

I am using Enterprise Library 4 on one of my projects for logging (and other purposes). I\'ve noticed that there is some cost to the logging that I am doing that I can miti

10条回答
  •  误落风尘
    2020-12-07 08:16

    An extra level of indirection may help here.

    Your first async method call can put messages onto a synchonized Queue and set an event -- so the locks are happening in the thread-pool, not on your worker threads -- and then have yet another thread pulling messages off the queue when the event is raised.

提交回复
热议问题