?
Solved

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

Posted on 2007-03-28
5
Medium Priority
?
1,354 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

764 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