"work please wait" screen with stream?

It may be very easy for you, but I work a lot on a project (for educational purposes) that requests adsi with the TADSISearch component for several days. I am trying to show the "Work, please wait .." screen saver with man animated gif in Form2, while TADSISearch is searching in Active Directory. Although I tried all the possibilities for me, but I could not succeed. I tried using TADSISearch in the stream, but the stream ends before the ADSI shuts down. I think TADSISearch is not thread safe. What do you think? Also, in another way that I created Form2, and used the stream to update it, but the animated gif stops until the main form passes adsi. What can you say about this? How can I make the standby screen while ADSISearch is running and keep responding to the main form. Application.ProcessMessages or the timer is also wrong. Thanks so much for reading and answering.

+4
source share
4 answers

The graphical user interface must be updated by the main thread. You have to put your search code in a separate thread, and while the crawler thread is running, your main thread may show the animation along with a β€œWait” message.

Your search stream can notify the main stream when a search is performed using any of the available synchronization technologies. The easiest way is to define a method in your stream class that stops the animation in the user interface, and pass this method Synchronize at the end of the Execute method of your search stream.

The code for your search stream will look something like this:

type TMyThread = class(TThread) private procedure NotifyEndOfThread; protected procedure Execute; override; end; implementation uses MainFormUnit; procedure TMyThread.NotifyEndOfThread; begin MainForm.ShowAnimation := False; end; procedure TMyThread.Execute; begin try {Add your search code here} finally Synchronize(NotifyEndOfThread); end; end; 

And your main stream code will be like this:

 TMainForm = class(TForm) ... private FShowAnimation : Boolean; procedure SetShowAnimation(Value: Boolean); public property ShowAnimation : Boolean read FShowAnimation write SetShowAnimation; end; procedure TMainForm.SetShowAnimation(Value: Boolean); begin FShowAnimation := Value; if FShowAnimation then {Add animation code here} else {Stop animation} end; 
+9
source

Perhaps you can try the following:

Threaded Splashscreen for Delphi
http://cc.embarcadero.com/Item/20139

I use this on a touch / terminal application (thin client, Wifi, RemObjects, etc.) and it works well! An animated gif also appeared.

+3
source

How to terminate the stream before the search is completed? If the search is performed in a stream and you have only one instance of the stream, it should work.

+1
source

Can you not just do

 f := TMyWaitForm.Create(self); try f.Show(); ...start the TADSISearch... finally FreeAndNil(f); end; 

Insert animated GIF into TMyWaitForm (which displays itself)?

I have a form of website development progress in my website builder program and it works like a charm.

You can even consider displaying status information in a wait form (if the TADSISearch component / software has a callback function or an event that can be scheduled).

Displaying the current clock showing the time it takes the process is also nice.

-one
source

All Articles