Solved

vb.net 2005 - threading...Parameter count mismatch.

Posted on 2007-03-28
5
1,336 Views
Last Modified: 2009-07-29
Prior question: http:/Q_22477527.html

This was working fine, but I attempted to add another (3rd instance) thread and I'm getting the error in the subject.

My first thread(s):

   Private Delegate Sub HistoryDelegate(ByVal strMsg As String)
    Sub ShowHistory - calls    HistoryData("Show") 'just shortening code here for posting...
    Sub AddToHistory - calls   HistoryData("Add")

    Private Sub HistoryData(ByVal strMsg As String)
        If Me.InvokeRequired Then
            ' if operating on a thread, invoke a delegate on the UI thread.
            Dim omd As HistoryDelegate = New HistoryDelegate(AddressOf HistoryData)
            Dim aResult As IAsyncResult = Me.BeginInvoke(omd, New Object() {strMsg})
            Me.EndInvoke(aResult)
            Return
        End If

        Select Case strMsg
            Case "Show"
                     'code to show history in my listbox
            Case "Add"
                     'code to add history to the listbox
        End Select
    End Sub

I believe that was working fine...called from a form-textup event using:
Dim tShowHistory As New Thread(AddressOf ShowHistory) 'ShowHistory()
tShowHistory.Start() 'haven't added anything for the 'add' portion yet

So, in that same event, I went to add another thread using:
Dim tUpdateQuota As New Thread(AddressOf UpdateQuotaDetail)
tUpdateQuota.Start()

Then I added
Private Delegate Sub UpdateQuotaDelegate()
    Private Sub UpdateQuota()
  If Me.InvokeRequired Then
            ' if operating on a thread, invoke a delegate on the UI thread.
            Dim shd As UpdateQuotaDelegate = New UpdateQuotaDelegate(AddressOf UpdateQuota)
            Dim aResult As IAsyncResult = Me.BeginInvoke(shd, New Object())
            Me.EndInvoke(aResult)
            Return
        End If
  'my code
End Sub

    Private Sub UpdateQuotaDetail()
        UpdateQuota()
    End Sub

Did I do something wrong?
0
Comment
Question by:sirbounty
  • 3
  • 2
5 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 18809331
Your "UpdateQuotaDelegate" does not receive any events but you are passing it "New Object()".

Try not passing it anything at all.

So instead of:

            Dim aResult As IAsyncResult = Me.BeginInvoke(shd, New Object())

Use:

            Dim aResult As IAsyncResult = Me.BeginInvoke(shd)

That's my GUESS...    ;)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18809338
Sorry...

This line:

     Your "UpdateQuotaDelegate" does not receive any events

Should read:

    Your "UpdateQuotaDelegate" does not receive any PARAMETERS
0
 
LVL 67

Author Comment

by:sirbounty
ID: 18809395
Trying it now sir!
0
 
LVL 67

Author Comment

by:sirbounty
ID: 18809403
Looks like we have a winner! :^)

Thank you very much!!!
0
 
LVL 67

Author Comment

by:sirbounty
ID: 18809458
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

785 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