我正在尝试用ZXing编写程序,该程序不断扫描键盘输入,将输入转换为QR码。然后使用BarcodeReader类读取此QR码。即使在包含对象的子例程完成之后,BarcodeReader也会保留此文件的资源。这使我无法保存新的QR码,因为它仍然在使用,因此会覆盖现有的QR码!为了解决这个问题,我试图为类调用析构函数,但是我找不到任何析构函数。对此问题的任何帮助将不胜感激。下面的代码是应该调用析构函数的地方。
'Read any 2D Barcode, this will only ever be a QR code for this project
Private Function read2D(location As String)
Dim reader = New ZXing.BarcodeReader()
Try
Dim result = reader.Decode(Bitmap.FromFile(location))
Return "Succesfully Read 2D Barcode:" + result.ToString
Catch ex As Exception
Return "Error Reading 2D Barcode"
End Try
End Function
答案 0 :(得分:0)
持有锁的BarcodeReader不是。 您必须处理从Bitmap.FromFile获得的位图实例。 https://msdn.microsoft.com/en-us/library/4sahykhd(v=vs.110).aspx