470,588 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,588 developers. It's quick & easy.

Raising Events; Halting Execution

Suppose I am writing a program that has to execute
as series of steps, but at several of the steps, I want
to wait for external events to occur.

For example ( and this relates to another of my posts ),
say I want to execute a method, then wait for a flag
file. Ok, someone suggested using FileSystemWatcher.

So then, say I do that, how do I make an internal event
halt execution on the main method, wait for the event
to be raised when the file appears and then continue
execution?

Jul 21 '05 #1
1 1392
If you didn't mind the thread being unresponsive you could put the thread to
sleep in a loop.

Suppose that your FileWatcher code set a property when the file was
available, say _FileAvailable
then on your waiting thread you have the loop (in VB.net)

While Not _FileAvailable
system.threading.thread.currentthread.sleep(500)
end while
' Code to run then the file is found

Hope this helps

Andrew Fell-Gordon
Sound Technologies Ltd
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Chris | last post: by
117 posts views Thread by Peter Olcott | last post: by
1 post views Thread by john bailo | last post: by
reply views Thread by Gregory Khrapunovich | last post: by
4 posts views Thread by Marcel van der Gragt | last post: by
4 posts views Thread by Dave A | last post: by
3 posts views Thread by =?Utf-8?B?THVib21pcg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.