Callbacks w/ Multiple Server Objects?
I'm trying to do something that is backward to every example I see.
I want to create ONE 'Client' that can create MULTIPLE Asynchronous ActiveX 'Servers' and keep track of them.
Each 'Server' instance will perform a task (email a set of people) and then tell the Client:
1. who it is (this particular instance)
2. It's Status (complete; error; etc.)
3. What the Error is if there is one.
4. Then DIE!
Basically, I'm trying to write a multithreaded mass emailer.
My problem is, my Client can only seem to see ONE instance of the Server.
In the Event Proc on the client it prints 10 of the SAME Key & CAnalysisID.
Also, the (and only one) Server keeps running after the Client Ends.
How can I make this work right?
Heres the code.
Private WithEvents oCA As AECEmailer.CAnalysis
Private CACount As Integer
Friend Sub DoBlast()
Dim i As Integer
CACount = 0
For i = 0 To 10
Set oCA = New AECEmailer.CAnalysis
oCA.CAnalysisID = 345 + i
oCA.Key = i
CACount = CACount + 1
Private Sub oCA_Status(ByVal nStatus As Long, nKey As Long, nCAnalysisID As Long, sError As String)
Debug.Print nStatus & ", " & nKey & ", " & nCAnalysisID & ", " & sError
CACount = CACount - 1
Private Sub WaitUntilDone()
Do Until CACount = 0
Private WithEvents Tmr As Timer
Private nKey As Long
Private nCAnalysisID As Long
Public Event Status(ByVal Status As Long, Key As Long, CAnalysisID As Long, Error As String)
Private Sub Class_Initialize()
Set fm = New fmTmr
Set Tmr = fm.tmrStart
Public Sub StartProcess()
Tmr.Enabled = True
Private Sub DoBlast()
RaiseEvent Status(0, nKey, nCAnalysisID, "Success")
Public Property Get Key() As Long
Key = nKey
Public Property Let Key(ByVal vNewValue As Long)
nKey = vNewValue + 3
Public Property Get CAnalysisID() As Long
CAnalysisID = nCAnalysisID + 5
Public Property Let CAnalysisID(ByVal vNewValue As Long)
nCAnalysisID = vNewValue
Private Sub Tmr_Timer()