EventLog类锁定文件 [英] EventLog class locks files
问题描述
我发现在使用类似下面的代码时也会锁定某些文件.我相信,当从具有eventlog map/info文件的应用程序中读取日志时,只要我的应用程序正在运行,该文件就会被锁定.
I have found that when using code like below also locks some files. I believe when reading a log from an application that has the eventlog map/info file in its own dll file, that file gets locked, as long as my application is running.
我在代码的每个部分都使用.Close和.Dispose,但文件已被锁定.
我发现,当根本不创建"new eventlog(xxx)"时,文件锁定永远不会发生.
I am using .Close and .Dispose in every part of my code, yet the file is locked.
I found that when simply not creating the "new eventlog(xxx)" the file locking never occours.
还有其他人提出来吗?
我在做什么错了?
我希望能够读取所有没有锁的日志.
Anyone else come up on this?
What am I doing wrong?
I would like to be able to read all logs, without the locks.
Sub New(ByVal _LogName As String)
LogName = _LogName
logobj = New EventLog(LogName)
AddHandler logobj.EntryWritten, AddressOf OnEntryWritten
End Sub
Private Sub OnEntryWritten(ByVal sender As Object, ByVal e As System.Diagnostics.EntryWrittenEventArgs)
Using e.Entry
RaiseEvent OnEntryWritten_Event(LogName, e.Entry)
End Using
End Sub
推荐答案
检查此:
http://www.thescarms.com/dotnet/EventLog.aspx
http://www.thescarms.com/dotnet/DebugTrace.aspx
这篇关于EventLog类锁定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!