c# - Load indicator Windows Forms -


i have 3 forms:

  1. login form
  2. browse users form
  3. user profile

and classes:

  1. user
  2. article
  3. app

so, forms creating reloaded constructor. 1 of them are:

public userprofile(user user)     {         initializecomponent();         show();         picturebox2.load("https://d13yacurqjgara.cloudfront.net/users/34535/screenshots/631316/loader_gif.gif");         string ajson = @client.downloadstring(app.host + "api/get_user_articles?e=" + app.email + "&p=" + app.password + "&u=" + user.id.tostring());         articles = jsonconvert.deserializeobject<list<article>>(ajson);         listview1.view = view.largeicon;         imagelist1.imagesize = new size(32, 32);         int = 0;         foreach (var article in articles)         {             listviewitem aview = new listviewitem(article.theme);             string aurl = client.downloadstring(app.host + "api/get_article_image?a=" + article.id);             if (!aurl.startswith("https://"))             {               aurl = app.host + "assets/fallback/default_article-f8a3a64f38bb9b0d777f6722ab64ca0c.png";             }             byte[] imagedata = client.downloaddata(aurl);             memorystream stream = new memorystream(imagedata);             image img = image.fromstream(stream);             stream.close();             imagelist1.images.add(img);             aview.imageindex = i;             listview1.items.add(aview);             i++;          }      } 

this code loading images , articles remote server. thih long-term process. need create lazy load effect beetween window show , window complete load. before i've tried create picturebox on top of form , send bottom when finish loading. doesn't work, because forms on sleep mode when downloading data. please write problem solutions! thank you!

the loading of pictures must performed in thread.

you can use backgroundworker, here's tutorial: http://www.dotnetperls.com/backgroundworker


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -