rowgram
December 9th, 2005, 05:55 PM
I've got a function that outputs an array. I'm calling it inside my code as :
function A (...,...,real_data).
Inside this function, I've got the following statement inside a loop with index i :
memcpy(&data[i], &source, sizeof(source));
My understanding is that this copies the data from buffer source to buffer data[i]. data is a struct & contains an int counter that I need to display immediately, so I do :
textBox1->set_Text(Convert::ToString(data[i].counter));
but I get 0. Is there some lag between when a destination buffer is copied to & when it's contents can be accessed ? How do I access counter ?
However, textBox1->set_Text(Convert::ToString(i));
works correctly - I see the correct values being displayed (the index scrolls).
Also when I exit out of the function, data - the output of the function - is now called real_data (see above) & accessing it via :
textBox1->set_Text(Convert::ToString(real_data[i].counter));
works fine.
But by then there's been a large delay between the data that has been received & when it is displayed. I guess I could create a 2nd thread, but I've never done this before, it looks daunting, & it seems that in this looping structure a set_Text call after memcpy could work without the need for threads (I'm sure I'll get a chance to work on a multi-threaded app, but I'm hoping to do this later when I have more time).
function A (...,...,real_data).
Inside this function, I've got the following statement inside a loop with index i :
memcpy(&data[i], &source, sizeof(source));
My understanding is that this copies the data from buffer source to buffer data[i]. data is a struct & contains an int counter that I need to display immediately, so I do :
textBox1->set_Text(Convert::ToString(data[i].counter));
but I get 0. Is there some lag between when a destination buffer is copied to & when it's contents can be accessed ? How do I access counter ?
However, textBox1->set_Text(Convert::ToString(i));
works correctly - I see the correct values being displayed (the index scrolls).
Also when I exit out of the function, data - the output of the function - is now called real_data (see above) & accessing it via :
textBox1->set_Text(Convert::ToString(real_data[i].counter));
works fine.
But by then there's been a large delay between the data that has been received & when it is displayed. I guess I could create a 2nd thread, but I've never done this before, it looks daunting, & it seems that in this looping structure a set_Text call after memcpy could work without the need for threads (I'm sure I'll get a chance to work on a multi-threaded app, but I'm hoping to do this later when I have more time).