ActiveX.exe's and CCRP Timers

Posted on 2011-04-19
Last Modified: 2012-05-11
Hello Experts, I have created an application to monitor up to 40 machines in an industrial environment. I use an activex.exe to make the network connection and monitor the machine. When the main application loads it looks at a list of IP Addresses and creates an instance of the activex.exe for each IP Address. Each instance is assigned to one machine. Within the activex.exe I am using the CCRP timer to get status information of the machine once every second. The first time the timer starts the network connection is established. Each time the timer fires it checks  the network connection. If there is a connection then it askes for the status of the machine.

I have found that I am only able to connect to 16 machines out of 40. In reading it appears that a 32 bit operating system can only run 16 timers per process. If that is what I am running into, then my activeX.exe's are not running in their own process. Is that right? So if my activex.exe's were each running in their own process then I should not have any trouble?

Can someone please verify this for me?
Question by:Basicfarmer
    LVL 2

    Expert Comment

    Hello, here my question is
    for each one IP there is one exe instance and for each instance there is one time running?
    or there are 40 IP and then each had got the Exe, and again each hs got one timer??
    can you please  explain the scenario in this manner
    LVL 17

    Expert Comment

    What Threading model did you select for the App (see Project Properties - General)?

    First you need to check that your local system can handle that many packets per second, this depends on your switch speed and ave. size of packets:

    Why don't you change the app into an event driven app.  Once a connection is established the remote client (which is in fact an IP server app) queues data into blocks and then simply sends the data back to the central system.

    All  the central system has to do then is monitor when the last packet was received from each remote.

    In this way you will cut down the bandwidth required by about 50% and the jobs the the server needs to do by 50%.

    After a few seconds of inactivity a remote can send an "I am still on line" packet.


    Author Comment

    I am usinig Thread Per Object threading model.

    The main program looks as a list of IP Address in a database. For each IP Address it creates the activex.exe which handles that machine. Each activeX.exe has a timer in it which is being used to poll the machine for status. There are 40 machines and so once the main program is up and running it has created 40 activex.exe's. One for each machine. All the activeX.exe's report status back to the main program which is just a GUI for the user. Currently everything works except I am only able to connect to 16 machines. I can disconnect one of the machines and another one will then connect. But I can only be connected to 16 machines at one time. I am using the CCRP multimedia timer in the activex'exe's and I am using the Dart Power TCP winsock tool for the connections.
    LVL 17

    Accepted Solution

    With an ActiveX EXE you only need one of them.  You can create a public class within the EXE.

    Re remote process can then create objects within the class (or the class can create objects within itself).

    You need just one form with a winsock on it.

    When the public class initialises it create a new instance of the form and maps to the winsock on the form so that class lock like this:

    ------------------Public Class Monitor.cls withn project called MyProject

    Option Explicit
    Dim MyForm As frmSock ' a form named frmSock with just a winsock on the form named WinSck
    Private WithEvents sckMyWinSock  As Winsock      

    Public IsConnected As Boolean
    Public LastActivity As Date

    Private Sub Class_Initialise()

    Set MyForm = New frmSock
    Set sckMail = MyForm.WinSck

    End Sub

    Public Sub Activate(psHost as String, plPort As Long)

    'Connect to host
    ' open an session...
    With sckMyWinSock
        If .state <> sckClosed Then
        End If
        .RemoteHost = psHost
        .RemotePort = plPort
        If .state <> sckClosed Then Exit Function
        pbConnected = False
    End With

    End Sub

    You can then active a new connection as follows:

    Dim Monitor(40)

    Set Monitor(0) = CreateObject("MyProject.Monitor")

    Monitor(0).Activate "", 12345

    Set Monitor(1) = CreateObject("MyProject.Monitor")

    Monitor(1).Activate "MyRemoteName", 12345

    Or create objects in a loop:

    For lc = 0 To Ubound sHostList()
        Set Monitor(lc) = CreateObject("MyProject.Monitor")

        Monitor(lc).Activate sMyHostList(lc), 12345

    The ActiveX EXE can also launch its own objects by creating instances within its own Sub Main()
    But the sub main should start a control form that then launches the classes.

    In this way you only have one exe running.

    The PC will have limitations but it is more likely to be able to able to handle one exe running 40 tasks.

    The control form could then look through each connected client using one timer.

    Private Sub MyTimer_Timer()

       lC = lC +1
       If lC> Ubound(msHostList) Then
       End If

       If Now-Monitor(lc).LastActivity> OneSecond Then
           Montor(lc).LastActivity = Now
           Exit Sub
       End If
    End Sub


    Author Comment

    OK, let me try and get my head around this a little bit and I will get back to you with some questions.
    LVL 17

    Expert Comment

    One exe with 40 jobs will use way less resources than 40 exes.

    The code for each job will only be in memory once even though it will have 40 data spaces.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now