views:

217

answers:

1

Hello. My C# application has a timer that triggers an event every 100 milliseconds. Inside this event there is a receive handler for bus traffic that loops continuously until the receive buffer is empty, or another 100 milliseconds has elapsed. This works fine until I try to use one of the other controls in my application at run time. Then the application freezes. Does anybody have any ideas how I may partition my application (or otherwise modify it), so that when I try to use a control, the background event (tied to the timer) can continue running and not stall the application? I am using Microsoft Visual C# 2008 Express Edition. Thanks.

+3  A: 

You have to use a BackgroundWorker (or an equivalent construct) for the receive handler. That way it will run in a different thread and the form will be able to respond timely, and you won't need a timer in the loop.

Vinko Vrsalovic
Indeed, read up on threading.
Paul Creasey
Vinko, thanks for the tip!
Jim Fell