471,313 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,313 software developers and data experts.

Waiting for a response file

I am writing a web service that sends work to a system that gets it's
work via XML files. This system looks for files in a particular
directory, processes the file, then leaves a response file in the same
directory. What is the best way to wait for the reponse file? Is there
a better way than going into the following loop?

while(!System.IO.File.Exists(reponseFile) {
System.Threading.Thread.Sleep(1000);
}

thanks,

-Keith
Jul 21 '05 #1
3 1542
Check out the FileSystemWatcher class. It is designed specifically for
that purpose.

Though, if you are trying to do it within the contexts of a single web
service call, you will have to put the method to Sleep indefinitely
(waiting for the FileSystemWatcher event to wake it up).

If the process takes a long time, it probably isn't an appropriate use
of web services. Asynchronous or long running tasks are a major
weakness in the web service programming model.
Do your systems need to communicate with each other over the public
internet? If not, you probably do not need web services, as they will
bring a lot of unnecessary restrictions to your scenario. You might
want to look into a queue based system instead.

Joshua Flanagan
http://flimflan.com/blog

Keith wrote:
I am writing a web service that sends work to a system that gets it's
work via XML files. This system looks for files in a particular
directory, processes the file, then leaves a response file in the same
directory. What is the best way to wait for the reponse file? Is there
a better way than going into the following loop?

while(!System.IO.File.Exists(reponseFile) {
System.Threading.Thread.Sleep(1000);
}

thanks,

-Keith

Jul 21 '05 #2
Joshau,

Thanks for the response. The directory won't be local to the hosts
needing this service. The communication will be over a LAN, not the
public internet. Can you give me more information regarding the 'queue
based system'? Maybe a link to some MSDN references?

thanks,

-Keith

Joshua Flanagan wrote:
Check out the FileSystemWatcher class. It is designed specifically for
that purpose.

Though, if you are trying to do it within the contexts of a single web
service call, you will have to put the method to Sleep indefinitely
(waiting for the FileSystemWatcher event to wake it up).

If the process takes a long time, it probably isn't an appropriate use
of web services. Asynchronous or long running tasks are a major
weakness in the web service programming model.
Do your systems need to communicate with each other over the public
internet? If not, you probably do not need web services, as they will
bring a lot of unnecessary restrictions to your scenario. You might
want to look into a queue based system instead.

Joshua Flanagan
http://flimflan.com/blog

Keith wrote:
I am writing a web service that sends work to a system that gets it's
work via XML files. This system looks for files in a particular
directory, processes the file, then leaves a response file in the same
directory. What is the best way to wait for the reponse file? Is there
a better way than going into the following loop?

while(!System.IO.File.Exists(reponseFile) {
System.Threading.Thread.Sleep(1000);
}

thanks,

-Keith


Jul 21 '05 #3
I was referring to products like Microsoft's MSMQ.
http://www.microsoft.com/windows2000...mq/default.asp

You can get an idea of how it is used with .NET here:
http://msdn.microsoft.com/library/de...tnetasync2.asp
(it also references an earlier article with .NET MSMQ basics)

You may also want to explore .NET Remoting. I think you may be able to
raise an event from a remotable object, so that your calling client is
notified when the process is complete (the response file appears).

Joshua Flanagan
http://flimflan.com/blog

Keith wrote:
Joshau,

Thanks for the response. The directory won't be local to the hosts
needing this service. The communication will be over a LAN, not the
public internet. Can you give me more information regarding the 'queue
based system'? Maybe a link to some MSDN references?

thanks,

-Keith

Joshua Flanagan wrote:

Check out the FileSystemWatcher class. It is designed specifically for
that purpose.

Though, if you are trying to do it within the contexts of a single web
service call, you will have to put the method to Sleep indefinitely
(waiting for the FileSystemWatcher event to wake it up).

If the process takes a long time, it probably isn't an appropriate use
of web services. Asynchronous or long running tasks are a major
weakness in the web service programming model.
Do your systems need to communicate with each other over the public
internet? If not, you probably do not need web services, as they will
bring a lot of unnecessary restrictions to your scenario. You might
want to look into a queue based system instead.

Joshua Flanagan
http://flimflan.com/blog

Keith wrote:
I am writing a web service that sends work to a system that gets it's
work via XML files. This system looks for files in a particular
directory, processes the file, then leaves a response file in the same
directory. What is the best way to wait for the reponse file? Is there
a better way than going into the following loop?

while(!System.IO.File.Exists(reponseFile) {
System.Threading.Thread.Sleep(1000);
}

thanks,

-Keith


Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Keith | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.