Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 3 Monaten
Letzter Beitrag:
vor 1 Jahr, 3 Monaten
Beteiligte Autoren:
Luis Antonio Gutiérrez Flores, Fabrice Harari, Yogi Yang

[WM20] - Fetching Image From Server to show in Image Control some times crashes

Startbeitrag von Yogi Yang am 08.05.2017 05:23


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")

HTTPRequest("http://xxxxxxxxxxxxxxx.xxx/photo_gallery/"; + PhotoFileName)

IF ErrorOccurred = False THEN
sResult is Buffer = HTTPGetResult(httpResult)
IF Position(sResult,"404") THEN
IF Length(sResult) > 0 THEN
IMG_Photo = sResult

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?




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

von Fabrice Harari - am 08.05.2017 12:36
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.


//Process Loading your image



von Luis Antonio Gutiérrez Flores - am 08.05.2017 16:06
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.