Vb.net 我应该在这些示例上实现IDisposable吗
样本1。(如果我的方法之一使用非托管对象)Vb.net 我应该在这些示例上实现IDisposable吗,vb.net,entity-framework,idisposable,Vb.net,Entity Framework,Idisposable,样本1。(如果我的方法之一使用非托管对象) 公共类记录器 '实现IDisposable每个post.run代码分析只问一个问题,它将告诉您应该实现它的类。 Public Class Logger 'Implements IDisposable <<< is this necessary because of unmanaged object inside the method? Public Sub CreateLogFile(ByVal msg As S
公共类记录器
'实现IDisposable每个post.run代码分析只问一个问题,它将告诉您应该实现它的类。
Public Class Logger
'Implements IDisposable <<< is this necessary because of unmanaged object inside the method?
Public Sub CreateLogFile(ByVal msg As String)
Try
If Not String.IsNullOrEmpty(_LogDir) Then
Try
Using objWriter As New System.IO.StreamWriter(Format(Now, "MM-dd-yyyy HHmmss") & ".txt", True)
objWriter.WriteLine(msg)
objWriter.Close()
End Using
Catch ex As Exception
End Try
End If
Catch ex As Exception
End Try
End Sub
End Class
Public Class frmViewerReport
'Implements IDisposable <<< is this necessary because of event I added in the winform?
Public Event DoneAutoPrint()
Public Event Progress()
Public Event ProgressDone()
Public Event ErrorRaised(ByVal msg As String)
End Class
Public Class MyRepository
'Implements IDisposable <<< is this necessary because of dbcontext?
Private _ctx As New MyEntities
Private _User As User
End Class
Public Class MyEntities
Inherits DbContext
End Class