c# - Update UI control from another thread while the UI is busy for time-consuming work -
my question how update ui controls (such progressbar) thread while ui thread busy querying database (running time-consuming stored procedure) ?
i checked these questions , still no solution found me.
- updating ui continuously while main thread busy
- how update gui thread in c#?
- run multiple ui threads
- cross-thread cross-form. display splash screen progress bar
i know 1 option time-consuming work using backgroundworker , update progressbar using reportprogress method, have problem in option because ui thread responsible instantiate , show form after querying database this:
form2 f2=new form2(); f2.show();
i recommend use backgroundworker
, put construction , presentation of form2
object in backgroundworker
's runworkercompleted
event handler, executes on ui thread when backgroundworker
finished. don't try update ui background thread. gui classes not threadsafe.
Comments
Post a Comment