Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 929739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:13:08+00:00 2026-05-15T20:13:08+00:00

i am using textchanged event and i disable it where i don’t need as

  • 0

i am using textchanged event and i disable it where i don’t need as following

object.Event -= new System.EventHandler(myHandler);
//my code which doesn't need event handler
object.Event += new System.EventHandler(myHandler);

i used many times like this. but i needed sometimes 2 disable code like this:

object.Event -= new System.EventHandler(myHandler);
object.Event -= new System.EventHandler(myHandler);

of course i finished it with 2 enable code

object.Event += new System.EventHandler(myHandler);
object.Event += new System.EventHandler(myHandler);

i don’t know yet why i needed 2 times remove event handler but it worked great.

but in 1 case i got problem.

it doesn’t work with 2 or more disable code.

my question is, how can i watch this eventhandler if it needs just one -= code or more?
or how can i manage it?
i always worked like this, to make sure that i always leave event handler as first time

object.Event -= new System.EventHandler(myHandler);
//my code which doesn't need event handler
object.Event += new System.EventHandler(myHandler);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:13:09+00:00Added an answer on May 15, 2026 at 8:13 pm

    My advice would be to stop removing and re-adding the event handler, and instead add a flag to your event handler itself which inhibits whatever activities you need to inhibit during these sections of code.

    You can either have a single boolean flag, or use some kind of reference count, depending on how you need to cope with nesting.

    If there’s some reason why you can’t change the existing event handler, what about creating a new event hander which you attach to Event, and call the old one from that?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using TextChanged event and when I am pressing keyboard, numbers are going
Is there anyway to trigger the textChanged event in a text area using javascript
I have a TextChanged event for my WPF TextBox as follows: private void textMatch_TextChanged(object
There is a TextChanged event for the RichTextBox, what I require is a TextChanging
I have an object Order with a simple event, Public Event ErrorOccurred(ByVal msg As
To keep code out of the view when using the Model-View-View Model pattern (aka
A coworker and I can't figure out why the EventHandlers in the following code
What I want to have is a custom object which provides some events. For
i am using ckeditor,now i want to translate the content in onChange event using
I am using C#.net Windows form , and I need to create a search

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.