C# System.Threading.Timer and its state object

Posted by Captain NedD on Stack Overflow See other posts from Stack Overflow or by Captain NedD
Published on 2010-04-22T10:36:12Z Indexed on 2010/04/22 10:43 UTC
Read the original article Hit count: 726

Filed under:
|

I am writing a C# program that uses System.Threading.Timer to timeout on a UDP socket ReceiveAsync call.

My program polls a remote device, sending a UDP packet and expecting one in return.

I use the timer in one shot mode calling Timer.Change every time I want a new timeout period.

For every occurance of a timeout I'd like the timeout handler to have a different piece of information.

If I change the object I pass to the Timer on creation it doesn't seem to change when the handler executes.

Is the only way to do this to destroy the timer and create a new one?

Thanks,

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#