sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
winningElevent's Avatar

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
LTCCTL's Avatar
LTCCTL August 20th, 2008 05:01 AM
Member - 47 Posts
#2: Re: Keep checking existing file?

Hi,

please provide information about the language and platform.

Regards
LTCCTL
winningElevent's Avatar
winningElevent August 20th, 2008 06:06 PM
Newbie - 11 Posts
#3: Re: Keep checking existing file?

opp sorry. I'm using C# under windowsXP and device is WM 5/6.

thanks.
winningElevent's Avatar
winningElevent August 20th, 2008 08:58 PM
Newbie - 11 Posts
#4: Re: Keep checking existing file?

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.


Expand|Select|Wrap|Line Numbers
  1.  
  2. System.Timers.Timer time;//global Timer variable;
  3.  
  4.  
  5.     private void StartTask()
  6.     {
  7.  
  8.             //Connect to device and copy test case file onto device.
  9.             using (RAPI rapi = new RAPI())
  10.             {
  11.                 rapi.Connect(true);
  12.                 rapi.CopyFileToDevice(testCaseFile, @"\" + testCaseFile, true);
  13.  
  14.                 if (rapi.DeviceFileExists(@"\" + deviceResultFile))
  15.                     rapi.DeleteDeviceFile(@"\" + deviceResultFile);
  16.  
  17.                 //Run the exe file.
  18.                 if (rapi.DeviceFileExists(@"\" + cameraDeviceExecutableFile))
  19.                     rapi.CreateProcess(@"\" + cameraDeviceExecutableFile);
  20.                 else
  21.                 {
  22.                     showTestImage(errorImage);
  23.                     cameraRichTxtBox.SelectionColor = Color.Red;
  24.                     cameraRichTxtBox.AppendText("\nDevice executable file does not exist.");
  25.                 }
  26.  
  27.                 Waiting();
  28.  
  29.                 if (rapi.DeviceFileExists(@"\" + deviceResultFile))
  30.                 {
  31.                     rapi.CopyFileFromDevice(deviceResultFile, @"\" + deviceResultFile, true);
  32.                     deviceResultFileExist = true;
  33.                 }
  34.                 else
  35.                 {
  36.                     showTestImage(errorImage);
  37.                     cameraRichTxtBox.SelectionColor = Color.Red;
  38.                     cameraRichTxtBox.AppendText("\nDevice Result file does not exist.");
  39.                     deviceResultFileExist = false;
  40.                 }
  41.  
  42.                 rapi.Disconnect();
  43.             }
  44.  
  45.        }
  46.  
  47.  
  48.  
  49.         //Function: Waiting
  50.         //Purpose: 
  51.         private void Waiting()
  52.         {
  53.             time = new System.Timers.Timer();
  54.             time.Elapsed += new ElapsedEventHandler(TimerEvent);
  55.             time.Interval = 1000;//each second will raise an event.
  56.             time.Enabled = true;
  57.         }
  58.  
  59.         private void TimerEvent(object source, ElapsedEventArgs e)
  60.         {
  61.             countWaiting++;
  62.             MessageBox.Show(countWaiting.ToString());
  63.  
  64.             if(countWaiting == 10)
  65.                 time.Enabled = false;
  66.         }
winningElevent's Avatar
winningElevent August 20th, 2008 10:05 PM
Newbie - 11 Posts
#5: Re: Keep checking existing file?

Please disregard this post because I misunderstood the Timer.
Reply
Not the answer you were looking for? Post your question . . .
197,027 members ready to help you find a solution.
Join Bytes.com

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.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Mobile Development Contributors