I know what you need to do
Here is the deal. The multithreading is bass ackwords. Yes, the Activex Exe is running in another thread, but the only way that VB can marshal events, properties, methods etc between your main app and the other thread is by using THE MESSAGE QUEUE. Yep....Vb uses SendMessage to send a message that encapsulates the property, method, event etc to your ActiveX Exe. So you wait till the activex exe finishes.
AHHHHHHHHHHHHHHHHHHH. Can't wait for VB.NET can we.
Anyway, the HACK you need to do isnt all that bad.
1) In your activex exe, make a stub function that fires a timer off. The timer will then execute the function that takes a long time to call. This allows the SendMessage to return to your program instantly!
I used szInput and nVal to show you you can pass any parameters you want to setup the function...just save them in module level variables...dont do any calculations. You need to exit this function fast so it doesnt hang up the caller.
g_obj this is so you can refer to your object in the timer stub.
Public hTimer&
Public Function DoSomethingThatTakesALongTime(byval szInput as string, byval nVal as integer)
set g_obj = me
hTimer = SetTimer(0, 0, 10, AddressOf HackTimer)
End function
2) Create a .bas module in your project...only funcs in .bas modules work with AddressOf
Public g_obj As YOURCLASS
Public Sub HackTimer(ByVal hWnd&, ByVal dwMsg&, idEvent&, ByVal dwTime&)
Call KillTimer(0, g_obj.hTimer)
' this is the function you really wanted to call!
' And it runs in its own thread.!!!
g_obj.TheFunction
End Sub
Of course, this aint perfect, you got to put a little more effort into this to prevent recursion and stuff like that, but this will work.
Have Fun.
- John