Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 24th, 2004, 08:18 AM
Authorized User
Points: 325, Level: 6
Points: 325, Level: 6 Points: 325, Level: 6 Points: 325, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Altamonte Springs, FL
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
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
        CACount = CACount + 1
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
End Sub

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

Professional Software Developer since 1994.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 02:39 PM.

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