Showing animated gif in C# while loading Data from SQL to multiple ListViews -


i have created application multiple people scan qr codes on products before dispatching.

the application created using winforms, c# language , sql database.

i using mdi form multiple forms scan products, generate mis, dashboard etc.

the application running pretty well, working on optimization.

i stuck in dashboard form, contains multiple pivot count database scan per users, scan per product, scanning done per hour etc.

the form working fine loading data takes time in want show animated gif untill process executed , listviews , labels updated.

using below code image not visible, when code run in background. please guide need do.

i have pasted 1 method example others similar:

  private void refreshbtn_click(object sender, eventargs e)     {          cursor.current = cursors.waitcursor;          picturebox2.visible = true;          displaystats();          cursor.current = cursors.arrow;          picturebox2.visible = false;     }  private void displaystats()     {     custscan();     datewiseqccount();     userwisescan();     userwisedscan();     daywisedispatchscan();     hourwiseqccount();     }  private void userwisescan()     {         string querystring = "select scanby,count(distinct refno),count(1) secrec scan='y' group scanby order 3,2 desc";         lstvuser.clear();         lstvuser.columns.add("user", 105);         lstvuser.columns.add("cust", 60);         lstvuser.columns.add("imp", 60);          using (sqlconnection conn = new sqlconnection(connectstring))         {             sqlcommand cmd = new sqlcommand(querystring, conn);             try             {                 conn.open();                 sqldataadapter adp = new sqldataadapter(querystring, conn);                 datatable dt = new datatable();                 adp.fill(dt);                 (int = 0; < dt.rows.count; i++)                 {                     datarow dr = dt.rows[i];                     listviewitem listitem = new listviewitem(dr[0].tostring());                     listitem.subitems.add(dr[1].tostring().padleft(3));                     listitem.subitems.add(dr[2].tostring().padleft(3));                     lstvuser.items.add(listitem);                 }             }             catch (exception ex)             {                 messagebox.show(ex.message);             }         }      } 

there not activity in fornt end return rows limited. majority of process being done in backend.

i want show picturebox animated gif.

add backgroundworker worker, assign dowork handler displaystats, method, , set event.result want display, on runworkercompleted event assign method update ui data in event.result

hope helps:

backgorund worker:

http://www.codeproject.com/articles/99143/backgroundworker-class-sample-for-beginners

http://www.codeproject.com/articles/228869/backgroundworker-and-ui-threads


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -