My desktop is really messy at the moment so I decided to create a program where you can drag a file it and it creates a shortcut. When the file is dragged in, I grab the file's icon and name and save it, then draw them to the WinForm through OnPaint(). I'm having trouble with this though, since even before I can drag the file into the form, the OnPaint() draws a huge red X and doesn't update. Here is my code (it's a picture):
And the OnPaint method:
My question is that is there anyway to delay the OnPaint() method to wait until it acquires the certain data it needs to draw properly, or any other drawing method I could use to paste the icon+file name to the WinForm?
P.S: I've tried using Thread.Sleep, but then I realized it sleeps the main thread so the Drag/Drop processes can't occur