Make window appear quickly

I have a long method which calculates invoices from a database, creates a PDF and sends each invoice as an email attachment. At the beginning of this method there is a line “winWait.Show”.

What is the best way to get this window to show sooner rather than later?

put everything but winWait.show into the action code of a timer on winWait, set to execute once only.

The window will appear, the timer will fire, and the code will be run.

2 Likes

Jeff is right

Splitting the SHOW away from the actual work will let the Show happen first then in the very short period timer the rest of the work can happen

You can just drop a timer control on the window, set its run mode to OFF and period to 0
Then in the Windows Open event set the run mode to Once and have it run the method that does all the work you mentioned

You could do all this in code but … myeh … six of one half dozen of the other

There are other ways as well but this is about the simplest

1 Like

Interestingly this problems are coming up with nearly every Desktop language. When multithreading it becomes even more important to really take care. It is also a common error people making not toe control their windows completely what makes it sometimes creapy. We had a customer project where once a year on over 200 workplaces a bug. They have never found out why. When. I rewrote the stuffs I asked them if they had problems with that window cause the timing could go wring and the data in the window are after incorrect

You can also just define the mode to Once visually (in the window editor). This removes the need to add an “Open” event just for that.

I do it this way to specifically avoid issues I’ve run into in the past

Maybe they’ve been solved but it was a bug that got closed as not reproducible

Doing it the way I outlined I’ve never had the issue repeat