PDA

View Full Version : A confuse problem about Application.Sleep?


pierre
04-20-2004, 01:34 AM
Hi all:
I have some codes as below:
--It uses Windows Media Player to open a file that the name is 12-128k_wma.wma

File.Run("AutoPlay\\Docs\\wmplayer.exe", "D:\\design-MM\\AUDIO\\source\\12\\wma\\12-128k_wma.wma", "", SW_SHOWNORMAL, false);

--Makes the application sleep for 343000 second
Application.Sleep (343000);

--Finds all open windows with the string "Windows Media Player" in the title and sends each of them a close message.

windows = Window.EnumerateTitles();

window_name = "Windows Media Player";

for handle, title in windows do

result = String.Find(title, window_name, 1, false);

if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end

At this time problem is appeared. If I uses upon codes, I must wait 343000 seconds to end, then I can use or open the application again. If I interrupt the application by manual during 34300 seconds, it has not responding. It must wait 343000 seconds to end that it can use again.

I wish When the application be opened by user, it can interrupt immediatly without waiting 343000 seconds to end. If I can't interrupt the application, it can go on working include 343000 seconds of waiting.

How can I do that it reach my demand? Who can teach me or give me an example? Thank you for advance!

About Application.Sleep command:
Can it other parameters or commands use together?
If it can do it, who has it examples for me?

TJ_Tigger
04-20-2004, 08:10 AM
That is what Application.Sleep does, it puts your AMS appliction to sleep and appears like it is non-responsive until it wakes up. If you want your application to remain responsive you can look at Page.StartTimer and start a timer for the duration, and when the timer expires it would then close your external window.

pierre
04-20-2004, 10:21 AM
Sorry, TJ_Tigger.
I still can't know how to do it. Can you make a simple example for me, please? How to use the Page.StartTimer to reach my demand? Thank you for advance.

TJ_Tigger
04-20-2004, 11:33 AM
There is an example here on how to use the timer.

http://www.indigorose.com/forums/showthread.php?t=7246