开发者

Asynchronous control validation

I need to va开发者_Python百科lidate a control input on losing focus. Normally I'd use the Validating event. However this process involves checking the entered data against a local database of over 280,000 postal codes. I'd like for this validation to occur asynchronously since there is no requirement for the user to wait for it before they can enter the remaining form data.

My first thought was to encapsulate the validation logic in its own method, bind a delegate to it and use BeginInvoke() and EndInvoke inside the control validation event since no possible result of the validation will require Cancel=True (they will simply change the control forecolor).

Is there any better method?


You might want to look at a BackgroundWorker


You might find a BackgroundWorker a good method of doing this.

One thing to consider is the user trying to submit the form before your validation has finished running.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜