Page 1 of 1

MultiThread problem

Posted: Fri Aug 29, 2008 6:42 am
by kursist

I have problem with the multithreading. I have looked at wxThread example. I am not sure if I am doing it the right way.

Here is the Steps in application:

Collect some data from a Grid,
Arrange it in a PDU
Send it via COM port,
Receive the answer,
Update the Grid.

The first tow step is done once, but the next three steps should put in an infinite loop. I am updating the Grid in a thread to prevent window freezing. There is start and stop button for the loop.

It works for one Grid, but with two grid, and two start and stop buttons the application hangs.

When I click on stop. Which thread should be stopped, as it is not placed in thread array in a specific location.

The code is exactly the wxThread example with only Start and Stop.

adv. thanks for you help,

;) meee

Posted: Fri Aug 29, 2008 2:05 pm
by Ugly!
You should NOT update or deal with any controls directly from the thread. The way to go here would be to have the thread to post an event on the parent. Then add this event to the parent's event table.

I'm also working with serial COM and that's the way it works for me.

Best regards, Matias