更新时间:2023-02-25 19:18:50
我认为如果
Call_To_Database_NotAsync 或服务器端函数不支持多个并行执行,因此可以观察到不良影响。找到一种方法来取消过时的请求。
button1.KeyDown+=async(o,n)=> {
//This is a search function, the user will type something on
// a textbox then in every keypress, the application will connect
//to the database and search if the typed data has been found
//then bind it to a gridcontrol
var getData=Task.Run(()=> Call_To_Database_NotAsync); var result=await getData; gridcontrol.Datasource=result; }
Is there a possibility that the grid control will contain no data at all when the user types fast and the connection to the database is slow?
Regards
I think that if Call_To_Database_NotAsync or server-side functions are not designed to support multiple parallel executions, then it is possible to observe undesirable effects. Find a way to cancel the requests that are obsolete.