c# - Winform application freezes -
c# - Winform application freezes -
i'm new developing winform application (using c# .net)
my application freeze , showing "not responding" when there many operations running behind, when involves lot of info reading/writing to/from database. application did not crash though, freeze until code behind finish executing.
my question is, how "unfreeze" application. example, user can still click "cancel" button terminate whatever operation running, or show progress bar or that?
your application freezes because has single thread, responsible both drawing ui , doing other 'heavy' operations (reading/writing database). when thread busy database, cannot refresh ui. should perform 'heavy' operations in background thread(s). main thread responsible refreshing ui , ready that. utilize backgroundworker
component run operations on background threads.
suggested reading: backgroundworker class sample beginners , how to: utilize background worker
c# winforms
Comments
Post a Comment