Application.DoEvents is freezing app

bonedoc

Well-known member
Joined
May 4, 2006
Messages
112
Programming Experience
Beginner
Ok, I have a process where I am getting a screenshot of a form. I wanted to make a button on the form invisible when I took the image, so I make it's visible property false before and then true after the image is taken. Well, it was working occasionally, but sometimes I can see the button on the image. So, I put an Application.DoEvents after I make the button's visible false. However, this causes the app to lock up. It does not do it all of the time, so I cannot figure it out. I also tried to do thread.sleep, but for some crazy reason, this does not hide the button in in time. It is almost like it sleeps before the app makes the button not visible. Does anyone know what I could do to allow the app to hide the button or check for it's visiblity until it is not visible?
 
Thread.Sleep will freeze app if it's UI thread, nothing happens in thread while thread sleeps. Never heard a bug about DoEvents before.
 
Back
Top