RE: C# Command to Wait a Specified Period of Time
- From: Misbah Arefin <MisbahArefin@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 14 Jan 2008 21:40:00 -0800
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.
- Prev by Date: Re: Passing events from the menu to a control
- Next by Date: order limit -- Re: filter for DataridView
- Previous by thread: Re: C# Command to Wait a Specified Period of Time
- Next by thread: filter for DataridView
- Index(es):
Relevant Pages
|