PictureBox visible property does not work… help please

前端 未结 3 1628
北荒
北荒 2021-01-13 00:10

I am using window app and C#.. i have a picture which is invisible at the start of the app.. when some button is clicked, the picture box has to be shown..

i use thi

3条回答
  •  轮回少年
    2021-01-13 00:52

    Your picture box will not be displayed because you are running other operations on the UI thread during the time you want the picture box to be displayed. The UI will not be re-painted (showing the picture box) until the UI thread becomes free - i.e. after your method.

    To overcome this, you need to first show the picture box, then fire off a thread to run your operations on (this will allow WinForms to happily continue interacting and painting the UI), then finish with a call back to the UI thread to hide the picture box.

    Refer to this StackOverflow Question for help on this multithreaded execution process.

提交回复
热议问题