Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-03-28
5
Medium Priority
?
1,358 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
[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
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

610 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