I am trying to convert some C# code to VB .Net and am having issues with some of the delgate conversions.
BackupLibraries.cs
Public Class Backup
{
public event EventHandler<BackupPEventArgs> Backup;
...
if (BackupProgress != null) BackupProgress(this, new BackupProgressEventArgs(percent_complete))
...
}
public class BackupEventArgs : EventArgs
{
private float percentage;
public BackupProgressEventArgs(float percentage)
{
this.percentage = percentage;
}
public float Percentage
{
get { return percentage; }
}
}
UnitTest.cs
public void BackupTest()
{
Backup bu = new Backup()
bu.BackupProgress += delegate(object sender, Backup.BackupEventArgs e)
{
Debug.WriteLine("Percentage: " + e.Percentage.ToString());
};
}
It's converting sb.Backup += delegate(object sender, SQLBackup.BackupProgressEventArgs e) and wiring it to the event in the other class I am having issues on.
In VB:
Backuplibraries.vb
Public Class Backup
Public Event Backup As EventHandler(Of BackupEventArgs)
...
RaiseEvent Backup(Me, New BackupEventArgs(percent_complete))
...
End Class
Public Class BackupEventArgs
Inherits EventArgs
UnitTest.vb
Public Class BackupTest
Dim bu As New Backup()
bu.BackupProgress = Sub(sender As Object, e As BackupEventArgs)
Debug.WriteLine(e.Percentage.ToString())
End Sub
End Class
Of course
bu.BackupProgress = Sub(sender As Object, e As BackupEventArgs)
Debug.WriteLine(e.Percentage.ToString())
End Sub
is where the issue I am having with the conversion from C# to .Net is.