如何解决CA1063从类中删除终结器,并将其添加到处理错误的代码中
我一直在努力避免这种警告,根据CA1063: Implement IDisposable correctly,我尝试并理解的是,终结器应该只将Dispose方法包含在false中。其余代码应写在其他地方。我尝试了类似Microsoft的示例那样的工具,但是当我添加Dispose方法时,出现一个错误,指出该dispose方法已经存在,Designer中已经存在的唯一Dispose。设计师是造成麻烦的人吗?
~TimerUpdate()
{
Dispose(false);
try
{
this.matlab = null;
this.command = null;
}
catch(Exception ex)
{
Console.WriteLine("Exception in " + this.GetType().Name + ".cs: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "(): " + ex.Message);
this.Dispose();
}
}
private void TimerUpdate_FormClosing(object sender,FormClosingEventArgs e)
{
try
{
this.updateRateBox_ValueChanged(sender,e);
this.updateRateCAN_ValueChanged(sender,e);
this.matlab = null;
this.Dispose();
}
catch(Exception ex)
{
Console.WriteLine("Exception in " + this.GetType().Name + ".cs: " + System.Reflection.MethodBase.GetCurrentMethod().Name + "(): " + ex.Message);
this.Dispose();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。