Solved

MethodInvoker and passing Arguments

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

809 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