473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Find file, not found? wait x seconds and try again

I have a function that converts a file to another formait. But sometimes it
might take up to 50-100 milliseconds before the file exists on the location
the folder is looking for.

I want something like

if file.exists(filename) then
convert(filename)
else
wait(100)
If file.exists(file) then
convert(filename)
end if

is there a wait function in vb.net?

I want to call the wait in a windows form application and not in the DLL
that reads the file and converts it....
Nov 21 '05 #1
9 6796
CT
Philip,

You might to take a look at the FileSystemWatcher class for this purpose.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:1F**********************************@microsof t.com...
I have a function that converts a file to another formait. But sometimes it
might take up to 50-100 milliseconds before the file exists on the
location
the folder is looking for.

I want something like

if file.exists(filename) then
convert(filename)
else
wait(100)
If file.exists(file) then
convert(filename)
end if

is there a wait function in vb.net?

I want to call the wait in a windows form application and not in the DLL
that reads the file and converts it....

Nov 21 '05 #2
I expect the file to exist, only 1 in the 10000 times I run the function the
file is created a few milliseconds later. Using filesystemwatcher would only
be useful if the file is always created after the function is started.

"CT" wrote:
Philip,

You might to take a look at the FileSystemWatcher class for this purpose.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:1F**********************************@microsof t.com...
I have a function that converts a file to another formait. But sometimes it
might take up to 50-100 milliseconds before the file exists on the
location
the folder is looking for.

I want something like

if file.exists(filename) then
convert(filename)
else
wait(100)
If file.exists(file) then
convert(filename)
end if

is there a wait function in vb.net?

I want to call the wait in a windows form application and not in the DLL
that reads the file and converts it....


Nov 21 '05 #3
Philip Wagenaar wrote:
is there a wait function in vb.net?

I want to call the wait in a windows form application and not in the
DLL that reads the file and converts it....


Are you looking for System.Threading.Thread.Sleep?

Andrew
Nov 21 '05 #4
its not running in a thread.

"Andrew Morton" wrote:
Philip Wagenaar wrote:
is there a wait function in vb.net?

I want to call the wait in a windows form application and not in the
DLL that reads the file and converts it....


Are you looking for System.Threading.Thread.Sleep?

Andrew

Nov 21 '05 #5
"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:1F**********************************@microsof t.com...
I have a function that converts a file to another formait. But sometimes
it might take up to 50-100 milliseconds before the file exists on the
location the folder is looking for.
I want something like

if file.exists(filename) then
convert(filename)
else
wait(100)
If file.exists(file) then
convert(filename)
end if


How is your Convert function working? I /assume/ it's running
some external process and it's this that isn't finishing "quickly"
enough.
Of so, look at the WaitForExit method on the Process class.

HTH,
Phill W.
Nov 21 '05 #6
I have a function that takes an xmldocument as parameter and returns the same
xmldocument.
The function does:
In the xmldocument I look for a filename. If I find a filename and it exits
on disk I replace the name of the file with it's contents encoded in mime
format. The function that does the mimeencoding is in the same class.

Problem is that the xml file and the file I covert to mime are copied into a
directory which triggers all of this. But sometimes the function for
converting the filename to its content in mime encoding is ran so quicky, it
is ran when the xml doucment is copied to the directory, but the copying of
the other file is not finished yet
"Phill. W" wrote:
"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:1F**********************************@microsof t.com...
I have a function that converts a file to another formait. But sometimes
it might take up to 50-100 milliseconds before the file exists on the
location the folder is looking for.
I want something like

if file.exists(filename) then
convert(filename)
else
wait(100)
If file.exists(file) then
convert(filename)
end if


How is your Convert function working? I /assume/ it's running
some external process and it's this that isn't finishing "quickly"
enough.
Of so, look at the WaitForExit method on the Process class.

HTH,
Phill W.

Nov 21 '05 #7
"Philip Wagenaar" <ph*************@online.nospam> schrieb:
its not running in a thread.
[...]
Are you looking for System.Threading.Thread.Sleep?


Sure, it's running in the application's main thread. Thus you can use
'Thread.Sleep(1000)' to block the thread for one second, for example.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #8
Philip Wagenaar wrote:
its not running in a thread.


Not even in the CurrentThread?

I could be wrong, but surely everything runs in a thread, including your
program?

Andrew
Nov 21 '05 #9
Philip,
| its not running in a thread.
Actually it is! As all code in .NET runs in a thread. If you don't create a
thread then its running in the thread that the OS created when it created
your process.

Thread.Sleep is a shared method, it works on the current thread.

--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net
"Philip Wagenaar" <ph*************@online.nospam> wrote in message
news:7B**********************************@microsof t.com...
| its not running in a thread.
|
| "Andrew Morton" wrote:
|
| > Philip Wagenaar wrote:
| > > is there a wait function in vb.net?
| > >
| > > I want to call the wait in a windows form application and not in the
| > > DLL that reads the file and converts it....
| >
| > Are you looking for System.Threading.Thread.Sleep?
| >
| > Andrew
| >
| >
| >
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Harlin Seritt | last post by:
I have a file that a few different running scripts will need to access. Most likely this won't be a problem but if it is, what do I need to do to make sure scripts don't crash because the input...
0
by: Tim Zych | last post by:
I am using asp.net and ado.net to update an Access 2000 database. It works OK except, after minimal use, I get an error message: ----------------------- "The search key was not found in any...
0
by: Manuel | last post by:
I have a page that uploads a file to the user. Since the file is created on the fly and it takes a few seconds to generate, I present a "Please Wait" screen until the file is uploaded. This is the...
15
by: Snuyt | last post by:
Hello, I want the program to wait a few seconds between executing code. It should look something like this: public sub xx() ...code... wait(2) 'wait 2 seconds ...code...
1
by: Johannes Kiehl | last post by:
guys, I need one more hint on this. I feel I am not tackling this in a php'ish way. I've been asking before, in this NG, how to monitor a (semaphore-like) file for timestamp changes, other...
4
by: tshad | last post by:
I have a filewatcher program that tells me that a file has been created in my folder. The problem I want to immediately move the file or access it. If the file is large, it not be completely...
9
by: tshad | last post by:
I am trying to get access to a file that may still being written because the file is so large (7-10MB). I get an error: The process cannot access the file 'c:\TestDocs\XMLFiles\492172.XML'...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
23
by: canabatz | last post by:
can someone please help me set up a loop to wait for a file to be exist? i got a automation program that download a file from my ftp ,proccessing the file and returning back the result as a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.