The following are repeated invention wheel events happening around you. If there are similarities, it is a coincidence.
1. Handle freezing of keyboard keysCode
AProgramClick the Enter key to select the first record in the list, and then click it to mark the record as "processed ". That is to say, continuous press of the Enter key will mark a large number of records as "handled"-no one will keep pressing the Enter key, but what if the press of the Enter key gets stuck?
Because this program is used in industrial scenarios, the number of times the return key is pressed is large, and the keyboard gets stuck after a long time. In order to solve the problem of key freezing, a piece of code is added in this program to determine whether the key is stuck. It took a lot of effort to write code and test.
In fact, Windows has built in this function, called "filter key", as long as you set it in "Control Panel-> keyboard.
2. Custom XML serialization
When a program transmits data through XML and other programs, it needs to control the content of XML and delete some elements in XML from a specific receiver ).
This program is. developed by. net, the XML generated uses the XML serialization method to serialize the class object into XML. The method to delete XML elements is to directly operate the serialized XML, use dom-like methods to search for a node and a node, find the target element, and delete it. If the XML structure has only one layer, the problem is not big, but if there are several layers, think about how terrible it is, for example
<A>
<B>
<B1> XXX </B1>
<C>
<C1> XXX </C1>
<D>
<D1> XXX </D1>
<D2> XXX </D2>
</D>
</C>
</B>
</A>
In fact,. NET provides two more convenient methods to deal with this situation: Custom serialization and XSLT (XSLT may be slightly less efficient ).