Keep checking existing file?
Question posted by: winningElevent
(Newbie)
on
August 20th, 2008 04:31 AM
Hi everyone,
I have a question would like to ask. So far I know how to retrieve files from device, but sometimes device takes so long to produce file so I want my desktop to keep checking every 3seconds to see if file exist. Here is the conditions.
1- if file exists after checking for exisitng is True, then desktop application will continue to do other stuff.
2- if file doesn't exist after three times of checking, then desktop sends messagebox unable to retrieve file.
can someone help me on that? I'm stuck on how can I keep checking every 3 seconds, but not more than 3 times.
thanks in advance.
4
Answers Posted
Hi,
please provide information about the language and platform.
Regards
LTCCTL
opp sorry. I'm using C# under windowsXP and device is WM 5/6.
thanks.
Quote:
Originally Posted by winningElevent
opp sorry. I'm using C# under windowsXP and device is WM 5/6.
thanks.
Sorry I sort change my approach now. Now I just want my desktop to wait for number of seconds before executing the next statement, and here is what I got so far, but it seems the Timer Event doesn't get executed property probably becauset he call to waiting() is executed after the copying the device result file if-statement.
-
-
System.Timers.Timer time;//global Timer variable;
-
-
-
private void StartTask()
-
{
-
-
//Connect to device and copy test case file onto device.
-
using (RAPI rapi = new RAPI())
-
{
-
rapi.Connect(true);
-
rapi.CopyFileToDevice(testCaseFile, @"\" + testCaseFile, true);
-
-
if (rapi.DeviceFileExists(@"\" + deviceResultFile))
-
rapi.DeleteDeviceFile(@"\" + deviceResultFile);
-
-
//Run the exe file.
-
if (rapi.DeviceFileExists(@"\" + cameraDeviceExecutableFile))
-
rapi.CreateProcess(@"\" + cameraDeviceExecutableFile);
-
else
-
{
-
showTestImage(errorImage);
-
cameraRichTxtBox.SelectionColor = Color.Red;
-
cameraRichTxtBox.AppendText("\nDevice executable file does not exist.");
-
}
-
-
Waiting();
-
-
if (rapi.DeviceFileExists(@"\" + deviceResultFile))
-
{
-
rapi.CopyFileFromDevice(deviceResultFile, @"\" + deviceResultFile, true);
-
deviceResultFileExist = true;
-
}
-
else
-
{
-
showTestImage(errorImage);
-
cameraRichTxtBox.SelectionColor = Color.Red;
-
cameraRichTxtBox.AppendText("\nDevice Result file does not exist.");
-
deviceResultFileExist = false;
-
}
-
-
rapi.Disconnect();
-
}
-
-
}
-
-
-
-
//Function: Waiting
-
//Purpose:
-
private void Waiting()
-
{
-
time = new System.Timers.Timer();
-
time.Elapsed += new ElapsedEventHandler(TimerEvent);
-
time.Interval = 1000;//each second will raise an event.
-
time.Enabled = true;
-
}
-
-
private void TimerEvent(object source, ElapsedEventArgs e)
-
{
-
countWaiting++;
-
MessageBox.Show(countWaiting.ToString());
-
-
if(countWaiting == 10)
-
time.Enabled = false;
-
}
Please disregard this post because I misunderstood the Timer.
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 197,027 network members.
Top Mobile Development Contributors
|