Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Guys

 

I am receiving an Object position changed event from another application.

when i handle the event i move another object in the application.

I need to stop the event getting handled a second time when i move the object as it crashes the applicaion.

How can i switch the event handler off while i move the object?

 

Thanks

phillip Restall
Posted

In C# it looks something like this:

this.btnTest.Click -= new System.EventHandler(this.btnTest_Click);

 

That will turn off the click event handler for "btnTest", and to turn it back on, you'd do this (notice any similarities to the first code?):

this.btnTest.Click += new System.EventHandler(this.btnTest_Click);

Posted
In C# it looks something like this:

this.btnTest.Click -= new System.EventHandler(this.btnTest_Click);

 

That will turn off the click event handler for "btnTest", and to turn it back on, you'd do this (notice any similarities to the first code?):

this.btnTest.Click += new System.EventHandler(this.btnTest_Click);

 

Thanks for the Reply, I'm using Visual basic

phillip Restall
  • Leaders
Posted

If you are using Handles, then you cannot turn it off and your best bet would be to wrap all of the inside code in an If block.

 

If you used AddHandler, then you can use RemoveHandler to remove the handler (equivalent to the example above). :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
If you are using Handles, then you cannot turn it off and your best bet would be to wrap all of the inside code in an If block.

 

If you used AddHandler, then you can use RemoveHandler to remove the handler (equivalent to the example above). :)

 

I'll have to try the Addhandler method.

 

how would i make that work? here is what i'm currently doing

 

 

Private sub blahblah() handles appx.position_change_event

appx.move("shape1",x,y)

end sub

phillip Restall
Posted

I got the add event handler woking but it did not help

The problem seems to be the other application.

It seems to crash when firing the second event when it has not recived the first one back (excuse my terminoligy lol)

I need to end the routine and then do the oject move.

I tried setting up a timer to run after the routine finishes that then moves the oject but the timer does not seem to work from my event (timer1.enabled=true)

Can anyone think of a way round this?

phillip Restall

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...