Invoe is being called twice for each action.

T

Tamir

Hi,
I wrote an addin for ms-word.
The addin inserts a button into ms-word.
The button events are sinked into a buttonHandler class.
THE PROBLEM IS:
For EACH TIME the button is pressed TWO calls to Invoke are made!!!
The most amassing part is that if I add a persistent counter into the code
of Invoke function, the counter increases only by one even though the program
passes through it twice.
I dont have any logical explanation to it -- to my opinion it may be related
(somehow) to synchronization but it can be any thing else ....
I dont have a clue, pleas help me. (By the way, even if it is related to
synchronization I would stile not know what to do ...).

Best regards.
 
T

Tamir

After some investigations I come with the following results:
1. if I add a counter to the "Invoke function" it counts each two calls as
ONE call - i.e. if I press the button, the debugger shows that we are getting
FOUR times into "Invoke" but the counter will have the value of TWO. Thus, I
cant go through by skipping ode calls.
2. If the button is pressed and through the first entrance to "Invoke" we
kill an object then the second time we are passing through "invoke" we will
have an error - the object is death. Well . . ., I can use it to overcome the
problem but it seems to me as VERY non-elegant way.
I dont know why it happens, and Im not sure I have any thing to do with it
since it is related to the hosting application (MS-Word).

Best regards,
 
C

Cindy M.

Hi =?Utf-8?B?VGFtaXI=?=,

If we don't know which version of Word you're working with, what kind of button,
and in what programming environment you created your add-in we can't begin to
even guess what might be going on.
I wrote an addin for ms-word.
The addin inserts a button into ms-word.
The button events are sinked into a buttonHandler class.
THE PROBLEM IS:
For EACH TIME the button is pressed TWO calls to Invoke are made!!!
The most amassing part is that if I add a persistent counter into the code
of Invoke function, the counter increases only by one even though the program
passes through it twice.
I dont have any logical explanation to it -- to my opinion it may be related
(somehow) to synchronization but it can be any thing else ....
I dont have a clue, pleas help me. (By the way, even if it is related to
synchronization I would stile not know what to do ...).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top