Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 24th, 2004, 08:18 AM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default Callbacks w/ Multiple Server Objects?

Hi:
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.
<CLIENT>
<code>
Option Explicit
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
        oCA.StartProcess
        CACount = CACount + 1
    Next
    WaitUntilDone
End Sub

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
End Sub

Private Sub WaitUntilDone()
    Do Until CACount = 0
        DoEvents
    Loop
End Sub
</code>
</CLIENT>

<SERVER>
<code>
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
    Load fm
    Set Tmr = fm.tmrStart

End Sub

Public Sub StartProcess()
    Tmr.Enabled = True
End Sub

Private Sub DoBlast()
    RaiseEvent Status(0, nKey, nCAnalysisID, "Success")
End Sub

Public Property Get Key() As Long
    Key = nKey
End Property

Public Property Let Key(ByVal vNewValue As Long)
    nKey = vNewValue + 3
End Property

Public Property Get CAnalysisID() As Long
    CAnalysisID = nCAnalysisID + 5
End Property

Public Property Let CAnalysisID(ByVal vNewValue As Long)
    nCAnalysisID = vNewValue
End Property

Private Sub Tmr_Timer()
    DoBlast
End Sub
</code>
</SERVER>



__________________
http://www.softlinksys.com
Professional Software Developer since 1994.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible Conflicting Callbacks wirerider ASP.NET 2.0 Professional 0 March 15th, 2007 10:35 AM
multiple documentElement (html) objects in one doc hussainm HTML Code Clinic 2 July 14th, 2006 02:40 PM
Server Control Objects sricinu General .NET 2 June 9th, 2005 07:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.