Is this thread.abort() normal and safe?

后端 未结 5 1359
刺人心
刺人心 2020-11-27 21:30

I created a custom autocomplete control, when the user press a key it queries the database server (using Remoting) on another thread. When the user types very fast, the pro

5条回答
  •  广开言路
    2020-11-27 22:01

    There are many warnings all over the net about using Thread.Abort. I would recommend avoiding it unless it's really needed, which in this case, I don't think it is. You'd be better off just implementing a one-shot timer, with maybe a half-second timeout, and resetting it on each keystroke. This way your expensive operation would only occur after a half-second or more (or whatever length you choose) of user inactivity.

提交回复
热议问题