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.

  1. updating ui continuously while main thread busy
  2. how update gui thread in c#?
  3. run multiple ui threads
  4. 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

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -