|
| Inicio → WINDEV 2024 → [WM20] - Fetching Image From Server to show in Image Control some times crashes |
| [WM20] - Fetching Image From Server to show in Image Control some times crashes |
| Iniciado por guest, 08,may. 2017 07:23 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 08,mayo 2017 - 07:23 |
Hello,
I am using Image Control to show images.
These images are on a remote web server.
I have set the Image Control's (Details) Zoom and scroll with fingers to Automatic Scroll and Zoom. Because of this User can swipe on the Image Control to load another Image from server.
I am first fetching the image name from remote MySQL database and I have the following code in the Horizontal and vertical swipe event for loading Image: IF InternetConnected() = False THEN Error("Internet not available") RETURN END HTTPRequest("http://xxxxxxxxxxxxxxx.xxx/photo_gallery/" + PhotoFileName) IF ErrorOccurred = False THEN sResult is Buffer = HTTPGetResult(httpResult) IF Position(sResult,"404") THEN Info(HTMLToText(sResult)) ELSE IF Length(sResult) > 0 THEN IMG_Photo = sResult END END END This is working perfectly as long as the user is patient and waits for the image to load. But if the user swipes multiple times in quick succession the app crashes.
How can I prevent this from happening?
TIA |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,mayo 2017 - 14:36 |
Hi
you could inactivate the swipe (or the whole window) on the first line of your code, thus FORCING the user to wait for the completion...
-AND- you could preload 2 or 3 images in the background so that they are available for the first swipe.
In that case, the code would become : - inactivate window - check if preloaded image is available - if YES: - display it, - activate window - start a secondary thread to replace the preloaded image by another one in your personal buffer - if NOT available (the user was REALLY too fast), revert to your actual code AND start a secondary thread to fill your buffer
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,mayo 2017 - 18:06 |
Here is an easier way to do this. Just use Hourglass, the same happened to me, if the user swiped too fast or clicked the next and back button too fast it crashed, so I used the next code to prevent this.
NextTitle("Loading...") Hourglass(TRUE)
//Process Loading your image
Hourglass(FALSE) NextTitle("")
 |
| |
| |
| | | |
|
| | | | |
| | |
|