duration of function

This is a discussion on duration of function within the C++ Programming forums, part of the General Programming Boards category; Hi. Im creating software for control a device , but i have problem. Code: ... Data = 0; i = ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    1

    duration of function

    Hi.
    Im creating software for control a device , but i have problem.

    Code:
    ...
    Data = 0;
    i = 0;
    while( i < NumberOfGate ){
    	if(FALSE == C8855ReadData( 	hC8855,
    					&CntData,
    					&ResultReturned)){;
    
    		Form1->Memo2->Lines->Add("Read data ERROR.");
    		return;
    	 }
    	Data = CntData + Data;
    	 i++;
    	 if( Terminated ) break;
    }
    DataArray[z] = Data ;
    ...
    Function C8855ReadData() read out data from device. Sometime is data lost by transmission of signal. At that time function (and software) to freeze, because still waiting to data.
    I need fixed this problem.

    Exist a function according any maximal time to executing my function
    ( C8855ReadData() )?

    thx .... PoolO
    Last edited by PoolO; 08-24-2010 at 07:50 AM.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    You will need to put this data grabbing into a thread of it's own, so you can wait for completion and if it does not finish in a set amount of time, do something about it (cancel, retry or whatever).
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    26
    Apart from the spawning a thread, another way is to use asynchronous read/write APIs.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Recursive function
    By WatchTower in forum C Programming
    Replies: 11
    Last Post: 07-15-2009, 08:42 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  4. Replies: 28
    Last Post: 07-17-2006, 12:35 AM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 07:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21