vb.net - Checking for existing path / filename is taking too long in VB -
i'm creating application has textbox attempts update picturebox when user enters filename.
it has preset directory users use, on shared network folder. checks if user inputting entire path , filename, display image accordingly.
the code works, however, if user starts typing in "c:\filename...", code hang several seconds after "c:". bigger issue have if user disconnects network drive, app maintain looking for 10 or 20 seconds, isn't necessary, i'd rather stop trying if doesn't see 2 seconds.
dim mycallback new image.getthumbnailimageabort(addressof thumbnailcallback) 'if user's entry exists filename, display in picturebox if dir(txtgrab.text) <> "" dim mybitmap new bitmap(txtgrab.text) dim mythumbnail image = mybitmap.getthumbnailimage(mybitmap.width, mybitmap.height, mycallback, intptr.zero) mythumbnail.getthumbnailimage(bordersize, bordersize, mycallback, intptr.zero) imgdisplay.image = mythumbnail end if 'if user's entry exists within intranet's path, display in picturebox if dir("\\intranet\images\" & txtgrab.text & ".tif") <> "" dim mybitmap new bitmap("\\intranet\" & txtgrab.text & ".tif") dim mythumbnail image = mybitmap.getthumbnailimage(mybitmap.width, mybitmap.height, mycallback, intptr.zero) mythumbnail.getthumbnailimage(bordersize, bordersize, mycallback, intptr.zero) frmcodegrabber.imgdisplay.image = mythumbnail end if
vb.net winforms
No comments:
Post a Comment