?
Solved

MethodInvoker and passing Arguments

Posted on 2011-02-18
2
Medium Priority
?
4,462 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

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

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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…
Suggested Courses

801 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