RE: C# Command to Wait a Specified Period of Time

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



while(true)
{
try
{
TryOpenFile(e.Name);
ProcessFile(e.Name);
break;
}
catch(Exception ex)
{
System.Threading.Thread.Sleep(1000);
continue;
}
}

--
Misbah Arefin



"Robert E. Flaherty" wrote:

What is the C# command to wait for a specified period of time?

I am writing a windows service that will process a file once it has beed
created or changed. I'm using the fileSystemWatcher to detect when a
specific file has been created or changed. That works fine to a point. The
event does fire when the file is being created or changed but I then blow up
when I attempt to open the file because the creation or changing has not
finished.

Using the try/catch structure, I am wanting to attempt to open the file. If
it is still being used, then wait a minute and try again. I rather use a
command (assuming that one exists) to sit there for say a minute and try
again.

Using a timer evolves a callback. I was hoping for a simple solution.
.



Relevant Pages

  • Re: Question about Eurekalog
    ... on out of college was as a technical writer for an Insurance group! ... Of course when you're writing tech documentation one can't meander off ... newsgroups like this I would not even bother coming here because I ... from Robert Meek dba Tangentals Design ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Freedom of speech lost; Imus isnt so bad as to be fired?
    ... effective writing. ... Robert, we can do this from the top. ... are responsible for the defense and advancement of free speech? ...
    (alt.usage.english)
  • Re: Question about Eurekalog
    ... It's funny you should say that, as one of the very first jobs I took ... If I tried in anyway to censor my writing on ... newsgroups like this I would not even bother coming here because I consider ... from Robert Meek dba Tangentals Design ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: mshtml and the click event inside of a windows service.
    ... don't have the time to write something that would be capable of doing posts ... Robert ... >> However, when I run the EXACT same code under a windows service, either ... Both GET and POST actions fail. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: mshtml and the click event inside of a windows service.
    ... don't have the time to write something that would be capable of doing posts ... Robert ... >> However, when I run the EXACT same code under a windows service, either ... Both GET and POST actions fail. ...
    (microsoft.public.dotnet.framework.windowsforms)