We have a file resizing and uploading operation that takes 6 to 10 seconds to complete:
Application.Eval(“toastr.info(‘Uploading photos…hang tight.’);”) ‘Show toast notification
PhotoEngine.ResizeAndUploadImages(strImageTemporaryFileName, p) ‘Resize and upload files … takes 6 to 10 seconds
Application.Eval(“toastr.clear();”) ‘Fade out toast notification if still there.
Application.Eval(“toastr.success(‘Success, the photos are now live!’);”) ‘Show success toast notification
The first “Uploading photos…hang tight.” does not display at all… not sure why. Is there an equivalent of Application.ProcessMessages?
What’s the best way to return information on the status of the longer operation? Would it be a WebWorker? An occasional call to a WebMethod on the parent form to update the UI?
I tried passing in a reference to a WiseJ.Web.Control, and updating its text property throughout the operation, but that had no effect. Just had a small spinner going after a while.
That is helpful thanks. So for solution 2, we call Application.StartTask with a lambda expression. I’m guessing the code can’t be in an external module then? Still figuring out lambda expressions/nested sub syntax in VB — it’s one of those things that code converters do not handle well.
When you get to step 2, the machine is processing the resize code, which means that the client is not receiving anything until it’s all done. It’s still a request/response cycle. Web workers cannot interact with the html elements at all.
Solution 1: you can add at step 1a Application.Update(this) but it will work only if the client supports WebSocket since it’s a push update and will send back every pending update.
Solution 2: you can process the file in a background task, see: http://demo.wisej.com/ProgressSample and https://wisej.com/blog/progress/, or http://demo.wisej.com/codeproject and related source code. There is also a background task example here: https://wisej.com/examples/
We also have the built-in toast boxes: AlertBox.Show().
I’d go for solution 2.
Please login first to submit.