Solved

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

Posted on 2007-03-28
5
1,333 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

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

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 …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.
Both in life and business – not all partnerships are created equal. Spend 30 short minutes with us to learn:   • Key questions to ask when considering a partnership to accelerate your business into the cloud • Pitfalls and mistakes other partners…

911 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

19 Experts available now in Live!

Get 1:1 Help Now