By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,537 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,537 IT Pros & Developers. It's quick & easy.

Keep checking existing file?

P: 15
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.
Aug 20 '08 #1
Share this Question
Share on Google+
4 Replies


P: 49
Hi,

please provide information about the language and platform.

Regards
LTCCTL
Aug 20 '08 #2

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

thanks.
Aug 20 '08 #3

P: 15
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.         }
  67.  
Aug 20 '08 #4

P: 15
Please disregard this post because I misunderstood the Timer.
Aug 20 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.