|
-
Mar 26th, 2004, 06:53 AM
#1
Thread Starter
Fanatic Member
ActiveX exe call back ***Resolved***
Hello,
I'm trying to get an active X exe to raise an event back to a standard exe
This is what I have so far
Client (standard exe)
VB Code:
Option Explicit
' Reference set to AlsServer under Project references
Private WithEvents myServer As AlsServer.cServer
Private Sub cmdCall_Click()
Set myServer = New AlsServer.cServer
End Sub
Private Sub myServer_doCallBack()
MsgBox "Your Call has matured!!", , "Als Server"
End Sub
Server (ActiveX exe)
VB Code:
Option Explicit
Event doCallBack()
Private Sub Class_Initialize()
doMyStuff
End Sub
Private Sub doMyStuff()
Dim i As Long, z As Long
z = 0
For i = 0 To 1000000
z = z + 1
If z = 999999 Then
RaiseEvent doCallBack
Exit For
End If
Next
End Sub
I've stepped through it and the raise event line is executed but doesn't get fired through to the client, does anyone know why?
Any help will be greatly appreciated
Regards Al
Last edited by aconybeare; Mar 29th, 2004 at 07:16 AM.
-
Mar 29th, 2004, 07:15 AM
#2
Thread Starter
Fanatic Member
I've resolved my problem and thought I should post the solution.
I've solved it by adding a timer to my Server via API Calls (SetTimer and KillTimer).
Why? My event never appears to fire, because instantiating the new object doesn't return until the loop is finished (the call to Initialize is syncronous).
By firing a timer (fake asyncronous method) with a short interval, which in turn disables the timer and calls the doMyStuff method. This allows the Initialize method to return immediately, the event then fires.
Note: I used a class and a standard module courtesy of a post by Woka Widget. If you want to use this there is a minor typo in the Class Terminate sub
replace it with this
VB Code:
Private Sub Class_Terminate()
mobjTimer.StopTimer 'This must be run to terminate the timerobject
Set mobjTimer = Nothing
End Sub
Cheers Al
-
Mar 29th, 2004, 11:18 AM
#3
Fanatic Member
Yes, COM calls are synchronous, even cross-thread or process.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|