Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.

Automation problems

Yametazamwa mara 0
Ruka hadi kwenye ujumbe wa kwanza ambao haujasomwa

Ophir

hayajasomwa,
1 Des 2004, 15:39:1401/12/2004
kwa
Hello all !

I have an App that uses an ActiveX EXE component.
The ActiveX exe is written with the thread per object option so each
object reside in it's own thread.

The app create a worker object from the ActiveX EXE. This object will
create other objects as needed during run time.

Now, I want all objects to report to the App certain things.
What I did is I create a Notify Object in the App and pass a reference
to the worker object which in turn will pass it to the objects it
creates.
So each object that is created will have a reference to this Notify
Object.
When something occure that needs to be reported back to the App, the
object that wants to report will call a Sub of the Notify Object. This
Sub raises an event that is caught by the App. The notify object is
declared in the App with the WithEvents statment. So all objects that
are created call the same Notify Object Sub to raise the event, and so
all of them report to the same place, which is the App that started
all of this.

How ever it seems that I have a problem with that since I sometimes
get an automation error saying " Method '~' of object '~' failed ".

Am I doing something wrong, or maybe a crime here?

Thanks

Ophir.

Steve Gerrard

hayajasomwa,
1 Des 2004, 23:59:1601/12/2004
kwa

"Ophir" <oph...@netvision.net.il> wrote in message
news:ec2c754d.04120...@posting.google.com...

I believe you have transgressed the unwritten law of interprocess
trans-thread method invocation. Say three Hail Bill's and no dessert for
you. :)

It's always hard to say with this sort of arrangement, but I think the
problem occurs when the sub-objects of your worker object call a method
of your app-created notify object directly, and it raises an event.
Which thread that all occurs on I can't say, but I'm betting it's the
wrong one.

I think you can fix this up with the following rearrangement:

Have the worker object create the notify object WithEvents, and have the
worker handle the notify object's event. The sub objects will still get
a reference to this notify object and still call its notify method.

Then, in the worker class, declare an event, and have the worker raise
this event in response to receiving a notify event from the notify
object. Your app then declares the worker WithEvents, and handles its
event.

The goal is to avoid having an object in the activex.exe call a method
of an object in your app, and to instead only raise events back to your
app.

Here it is as a rough schema, assuming you already have a cNotify class
that raises a Notify event:

'--- worker class

public event Notify()

private withevents notifier as cNotify

private sub class_initialize()
set notify = new cNotify
end sub

private sub notifier_notify()
raiseevent Notify
end sub

private sub MakeSubObjects()
' give each object a ref to notifier
end sub

'--- main app

private withevents worker as cWorker

private sub worker_Notify()
' do something
end sub


Ophir

hayajasomwa,
2 Des 2004, 02:37:1102/12/2004
kwa

Thank you Steve. I will try it and post a reply as soon as I get
results.

Ophir

Stefan Poehn

hayajasomwa,
9 Des 2004, 11:20:3809/12/2004
kwa

"Ophir" <oph...@netvision.net.il> schrieb im Newsbeitrag
news:ec2c754d.04120...@posting.google.com...
> Hello all !
>
> [...]

> How ever it seems that I have a problem with that since I sometimes
> get an automation error saying " Method '~' of object '~' failed ".
>

I had encountered the same problem when I compiled a VB program on Windows
XP and let it run on Windows 2000. Perhaps you committed a similar crime.

> Thanks
>
> Ophir.


Ophir

hayajasomwa,
9 Des 2004, 13:59:1209/12/2004
kwa

Thanks for the reply.
How ever I did not commited that crime.
It was compiled and run on the same machine running win 2000
Thanks again
Ophir

Ujumbe 0 mpya