Question : VB.NET - New to MultiThreading - Parameter Count Mismatch

Hi All,

I'm new to multi threading and require assistance in trying to make this application i'm developing run smoother.

I keep getting the Parameter Count Mismatch error on the Invoke() command, but cannot work out what I'm doing wrong... Have tried a few things but to no avail.

The code of the form in question is attached.

All the updating is actually on that specific form, no updating is taking place on the main MDIParent, and the subs UpdateBlacklist and UpdateGreylist are not actually passing any parameters so I'm not too sure exactly where i'm going wrong.

Any assistance you can provide is greatly appreciated

Thanks in Advance

Cheers,
Ray.



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
Imports System.Threading
Imports System.Data.SqlClient

Public Class frmTradingCentral


    Private Delegate Sub UpdateBlacklistDelegate(ByVal BlacklistObject As Object)
    Private Delegate Sub UpdateGreylistDelegate(ByVal GreylistObject As Object)

    Private Sub frmTradingCentral_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim ThreadUpdateBlacklist As New System.Threading.Thread(AddressOf UpdateBlacklist)
        Dim ThreadUpdateGreylist As New System.Threading.Thread(AddressOf UpdateGreylist)

        ThreadUpdateBlacklist.Start()
        ThreadUpdateGreylist.Start()

        With tmrRefreshBlacklist
            .Interval = 30000
            .Enabled = True
            .Start()
        End With

        With tmrRefreshGreylist
            .Interval = 30000
            .Enabled = True
            .Start()
        End With

    End Sub

    Private Sub UpdateBlacklist()

        Dim UpdateBlacklistThreadID As Integer = Threading.Thread.CurrentThread.ManagedThreadId
        Dim BlacklistDelegate As New UpdateBlacklistDelegate(AddressOf UpdateBlacklist)
        Dim BlacklistParams(1) As Object
        BlacklistParams(0) = rleTradingCentral_BlacklistStatus
        BlacklistParams(1) = rssTradingCentral_Blacklist

        If Me.InvokeRequired Then
            '************* FAILS HERE ****************
            Me.Invoke(BlacklistDelegate, BlacklistParams)
            '************* FAILS HERE ****************
        Else
            'Load/Refesh Blacklist Table
            Me.ViewBlacklistedClientsTableAdapter.Connection.ConnectionString = My.Settings.eTASConnectionString
            If Me.ViewBlacklistedClientsTableAdapter.Connection.State <> ConnectionState.Open Then
                With Me.ViewBlacklistedClientsTableAdapter
                    .Connection.Open()
                    .Fill(Me.DsBlacklistedClients.viewBlacklistedClients)
                    .Connection.Close()
                End With
            Else
                With Me.ViewBlacklistedClientsTableAdapter
                    .Fill(Me.DsBlacklistedClients.viewBlacklistedClients)
                    .Connection.Close()
                End With
            End If

            Me.ViewBlacklistedClientsBindingSource.ResetBindings(True)

            rgvTradingCentral_Blacklist.Columns(0).HeaderText = "Blacklisted Clients"
            rgvTradingCentral_Blacklist.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
            For Each BlackListColumn As Telerik.WinControls.UI.GridViewDataColumn In rgvTradingCentral_Blacklist.Columns
                BlackListColumn.AllowResize = False
            Next

            With rgvTradingCentral_Blacklist
                .Update()
                .Refresh()
            End With

            BlacklistParams(0).Text = "Last Updated: " & FormatDateTime(Now, DateFormat.LongTime)
            BlacklistParams(1).Refresh()

        End If

    End Sub

    Private Sub UpdateGreylist()

        Dim UpdateGreylistThreadID As Integer = Threading.Thread.CurrentThread.ManagedThreadId
        Dim GreylistDelegate As New UpdateGreylistDelegate(AddressOf UpdateGreylist)
        Dim GreylistParams(1) As Object
        GreylistParams(0) = rleTradingCentral_GreylistStatus
        GreylistParams(1) = rssTradingCentral_Greylist

        If Me.InvokeRequired Then
            '************* FAILS HERE ****************
            Me.Invoke(GreylistDelegate, GreylistParams)
            '************* FAILS HERE ****************
        Else
            'Load/Refesh Greylist Table
            Me.ViewGreylistedClientsTableAdapter.Connection.ConnectionString = My.Settings.eTASConnectionString
            If Me.ViewGreylistedClientsTableAdapter.Connection.State <> ConnectionState.Open Then
                With Me.ViewGreylistedClientsTableAdapter
                    .Connection.Open()
                    .Fill(Me.DsGreylistedClients.viewGreylistedClients)
                    .Connection.Close()
                End With
            Else
                With Me.ViewGreylistedClientsTableAdapter
                    .Fill(Me.DsGreylistedClients.viewGreylistedClients)
                    .Connection.Close()
                End With
            End If

            Me.ViewGreylistedClientsBindingSource.ResetBindings(True)

            Me.rgvTradingCentral_Greylist.Columns(0).HeaderText = "Greylisted Clients"
            rgvTradingCentral_Greylist.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
            For Each GreyListColumn As Telerik.WinControls.UI.GridViewDataColumn In rgvTradingCentral_Greylist.Columns
                GreyListColumn.AllowResize = False
            Next

            With rgvTradingCentral_Greylist
                .Update()
                .Refresh()
            End With

            GreylistParams(0).Text = "Last Updated: " & FormatDateTime(Now, DateFormat.LongTime)
            GreylistParams(1).Refresh()
        End If

    End Sub

    Private Sub tmrRefreshBlacklist_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRefreshBlacklist.Tick
        UpdateBlacklist()
    End Sub

    Private Sub tmrRefreshGreylist_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrRefreshGreylist.Tick
        UpdateGreylist()
    End Sub
End Class

Answer : VB.NET - New to MultiThreading - Parameter Count Mismatch

Hello,

1) BES uses one MAPI client per BES server. In your case, where you have 10 BES servers, you have 10 MAPI clients operating.

2) NSPI is used by the MAPI client to retrieve information from the directory. Without an NSPI connection, the MAPI client will not function and BES will stop working properly.

3) Assuming your 10,000 users are spread evenly over the 10 BES servers, you would need to set the reg key to 10,000 (1000 connections per server X 10 servers)

4) Yes, you can use multiple BES service accounts but it is a one-to-one ratio of service account to server. In your case, you could use 10 different service accounts (1 per server). In that case, you could set the reg key to 1000. Here is information on how you change the service account - http://www.blackberry.com/btsc/viewContent.do?externalId=KB04293&sliceId=1

JJ
Random Solutions  
 
programming4us programming4us