Keep checking existing file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • winningElevent
    New Member
    • Oct 2007
    • 15

    #1

    Keep checking existing file?

    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.
  • LTCCTL
    New Member
    • Feb 2008
    • 49

    #2
    Hi,

    please provide information about the language and platform.

    Regards
    LTCCTL

    Comment

    • winningElevent
      New Member
      • Oct 2007
      • 15

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

      thanks.

      Comment

      • winningElevent
        New Member
        • Oct 2007
        • 15

        #4
        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.


        Code:
                
        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;
                }

        Comment

        • winningElevent
          New Member
          • Oct 2007
          • 15

          #5
          Please disregard this post because I misunderstood the Timer.

          Comment

          Working...