I have an autocompleate textbox that looks into a data base. Some times while I\'m typing I received the following error.
Attempted to read or write protected memory
You can use lock:
private void tBSearchName_TextChanged(object sender, EventArgs e) { lock(this) { /* do magic */ }
Do note that it's bad practice to perform long tasks in the event handlers. If the search takes more then 30ms, better use a worker thread.