Solved

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

Posted on 2007-03-28
5
1,329 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
Comment Utility
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
Comment Utility
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
Comment Utility
Trying it now sir!
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
Looks like we have a winner! :^)

Thank you very much!!!
0
 
LVL 67

Author Comment

by:sirbounty
Comment Utility
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

10 Experts available now in Live!

Get 1:1 Help Now