However, I just tested with the agent demo and that works fine in a thread. You have set the threadsafe switch I take it?
In itself COMatePLUS is threadsafe and I have applications which use it in threads and I have had no problems. COMatePLUS initialises the COM environment on any thread used to create an object so that is no problem. What you cannot do is pass objects between threads because PB initialises the COM environment to a single threaded apartment. Other than that COMate itself should give you no problem.
Try the following (set the threadsafe switch) :
Code: Select all
IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
Procedure StartFilter(MyFilter$)
Define.COMateObject AgentObject, GenieObject
If ExamineDesktops()
cWidth = DesktopWidth(0) / 2 - 50
cHeight = DesktopHeight(0) / 4
EndIf
AgentObject = COMate_CreateObject("Agent.Control")
If AgentObject
AgentObject\SetProperty("Connected=#True")
AgentObject\Invoke("Characters\Load('Genie')")
GenieObject = AgentObject\GetObjectProperty("Characters('Genie')")
If GenieObject
GenieObject\Invoke("Show")
Delay(300)
GenieObject\Invoke("MoveTo("+StrU(cWidth)+", "+StrU(cHeight)+", 5000)")
GenieObject\Invoke("Play('Greet')")
GenieObject\Invoke("Speak('Hello, feel the ..Pure.. Power of Purebasic!')")
GenieObject\Invoke("Play('Reading')")
Delay(20000)
GenieObject\Invoke("Stop")
GenieObject\Invoke("Speak('Purebasic is a nice computer language.')")
Delay(6000)
MessageRequester("Agent", "Click ok to end")
GenieObject\Invoke("Play('Hide')")
Delay(3000)
GenieObject\Release()
Else
MessageRequester("Problem!", COMate_GetLastErrorDescription())
EndIf
AgentObject\Release()
Else
MessageRequester("Problem!", COMate_GetLastErrorDescription())
EndIf
EndProcedure
Procedure MyThread(null)
StartFilter("Y:\MyFilter.fll")
EndProcedure
OpenConsole()
CreateThread(@MyThread(),0)
PrintN("Press return to exit")
Input()
CloseConsole()
**EDIT : it seems to me that with the code you posted, you may have multiple threads trying to access the same file ("Y:\MyFilter.fll"). It could well be this which is screwing things up or something else to do with this component class. What happens if you only run a single thread (with the threadsafe switch!) Does it still crash?