Solved

MethodInvoker and passing Arguments

Posted on 2011-02-18
2
4,200 Views
Last Modified: 2012-06-21
Probably another easy question, but I'm stumped.

So, if InvokeRequired is true then it invokes.  But the function has arguments.

Either way, if I pass them after AddressOf, the compiler complains.

If i dont pass them, vb.net has a problem, says I need to pass them.


Public Sub addscandata(ByVal target As String, ByVal port As Integer, ByVal stat As String)

        If Me.InvokeRequired Then
            Me.Invoke(New MethodInvoker(AddressOf addscandata()))
        Else

            rtb_scan_data.AppendText(stat & ":" & target & ":" & port)

        End If
    End Sub

Open in new window

0
Comment
Question by:highrate
2 Comments
 

Author Comment

by:highrate
ID: 34929666
Sorry, don't know how I added C# to the zone.
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34929749
Create a delegate with the same signature as your method and then use it along with an array of object to pass the parameters:
Public Delegate Sub ScanDataDelegate(ByVal target As String, ByVal port As Integer, ByVal stat As String)

    Public Sub addscandata(ByVal target As String, ByVal port As Integer, ByVal stat As String)
        If Me.InvokeRequired Then
            Me.Invoke(New ScanDataDelegate(AddressOf addscandata), New Object() {target, port, stat})
        Else
            rtb_scan_data.AppendText(stat & ":" & target & ":" & port)
        End If
    End Sub

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now