Solved

MethodInvoker and passing Arguments

Posted on 2011-02-18
2
4,233 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

919 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

14 Experts available now in Live!

Get 1:1 Help Now