Using C# is it possible to test if a lock is held on a file

后端 未结 5 1626
我寻月下人不归
我寻月下人不归 2021-01-22 17:51

BACKGROUND: I use an offset into a file and the Filestream lock/unlock menthods to control read/write access. I am using the following code to test if a lock i

5条回答
  •  抹茶落季
    2021-01-22 18:38

    In some circumstances you can also use WCT, it's usually implmented by debugger's or profilers, however it can be used from any code as the usual debugger requirement of being the thread which has the debug port open is not a pre-requisit. As such WCT is a very comprehensive and precise information regarding lock contention.

    A managed example (all-be-it somewhat trickey), show's utility for this specific sub-set of the native debug API's on the CLR.

提交回复
热议问题