Clé*_*ent 3 vb.net lambda pass-by-reference byref
我正在使用SharpZipLib来压缩文件.该库包含在一个插件接口中,位于一个单独的DLL中.我通过插件dll一个ByRef参数来跟踪压缩进度.
SharpZipLib在压缩时会定期调用启动压缩时传递的委托子.我无法弄清楚在ByRef调用委托时如何更新参数.如果我尝试ByRef在lamba表达式的主体中分配变量,我会收到'ByRef' parameter '<parametername>' cannot be used in a lambda expression错误.
这是我的代码:
Using InputFile As New IO.FileStream(SourceFile, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using OutputFile As New IO.FileStream(DestFile, IO.FileMode.Create)
Using GZipStream As New GZipOutputStream(OutputFile)
Dim Buffer(524228) As Byte
Dim Handler As New ProgressHandler(Sub(Sender As Object, EventArgs As ProgressEventArgs) Progress += EventArgs.Processed)
StreamUtils.Copy(InputFile, GZipStream, Buffer, Handler, New TimeSpan(10000000), Nothing, "")
End Using
End Using
End Using
Run Code Online (Sandbox Code Playgroud)
谢谢!