代码之家  ›  专栏  ›  技术社区  ›  Jim

是否可以将vb2005中的子或函数中的参数作为数组获取?

  •  1
  • Jim  · 技术社区  · 17 年前

    是否可以将vb2005中的子或函数中的参数作为数组获取?

    4 回复  |  直到 17 年前
        1
  •  0
  •   ozczecho    17 年前

    使用反射:

    Dim params() As System.Reflection.ParameterInfo = myObject.GetType().GetMethod("myObjectMethodName").GetParameters()
    
        2
  •  1
  •   invert    17 年前

    你解决了吗?我不太确定您的意思,但是从您对OP的评论来看,您是否希望同步线程以使调用线程安全?

    Private WithEvents theThread As New threadedClass
    Private Delegate Sub threaded_method_delegate(ByVal sender As Object, ByVal var1 As Integer, ByVal var2 As String)
    
    Sub threaded_method(ByVal sender As Object, ByVal var1 As Integer, ByVal var2 As String) Handles theThread.threaded_method
        If Me.InvokeRequired Then
            ' invoke this method on the same thread as 'Me'
            Dim d As New threaded_method_delegate(AddressOf threaded_method)
            d.Invoke(sender, var1, var2)
        Else
            ' this method is now running on the same thread
            ' do stuff here
        End If
    End Sub
    
        3
  •  0
  •   Jonathan Allen    17 年前

    你可以在2010年,而不是2005年。这是通过DLR或动态语言运行库添加的功能。

        4
  •  0
  •   Rabid    17 年前

    如果您可以控制成员签名,那么可以将所有参数封装到一个类中,就像 EventArgs 对象(或其子类)以常规.NET方式在事件处理程序之间传递。

    然后通过传递对封装类本身的引用来传递所有值。

    推荐文章