我得到未为参数“sender"和“e"指定的参数? [英] I get argument not specified for parameters 'sender' and 'e'?

查看:25
本文介绍了我得到未为参数“sender"和“e"指定的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Call.ProgressUpdate() 来调用:

Public Sub ProgressUpdate(sender As Object, e As DownloadProgressChangedEventArgs)
    Console.WriteLine("{0}% completed", e.ProgressPercentage)
    Call Main2()
End Sub

但我收到错误:

未为Public Sub ProgressUpdate(sender As Object, e As System.Net.DownloadProgressChangedEventArgs)"的参数sender"指定参数.

Argument not specified for parameter 'sender' of 'Public Sub ProgressUpdate(sender As Object, e As System.Net.DownloadProgressChangedEventArgs)'.

未为Public Sub ProgressUpdate(sender As Object, e As System.Net.DownloadProgressChangedEventArgs)"的参数e"指定参数.

Argument not specified for parameter 'e' of 'Public Sub ProgressUpdate(sender As Object, e As System.Net.DownloadProgressChangedEventArgs)'.

任何帮助将不胜感激.

推荐答案

不是很清楚为什么要直接调用这个方法,它应该是一个事件处理程序.您需要传递它需要的参数,但这不会起作用,因为您无法创建 DownloadProgressChangedEventArgs 类的实例,其构造函数不可访问.您需要将其分解为两个单独的方法,如下所示:

It isn't very clear why you are calling this method directly, it is supposed to be an event handler. You'll need to pass the arguments it needs, but that isn't going to work because you cannot create an instance of the DownloadProgressChangedEventArgs class, its constructor is not accessible. You'll need to break this up into two separate methods, like this:

Private Sub ProgressUpdate(sender As Object, e As DownloadProgressChangedEventArgs)
    ShowProgress(e.ProgressPercentage)
End Sub

Private Sub ShowProgress(percentage As Integer)
    Console.WriteLine("{0}% completed", percentage)
End Sub

现在您可以简单地调用 ShowProgress(0).

Now you can simply call ShowProgress(0) instead.

这篇关于我得到未为参数“sender"和“e"指定的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆