المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Timeout for an operation



C# Programming
12-30-2009, 04:31 AM
Hi,
I need to implement a timeout expression.
Forexample like in services there is:

TCPIPServiceController.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 10));

Where it checks for 10 sec whether the service has reached a running state, else exception.

What i need is a customized similar expression (one line) implementing timeout, where i need to check the state of a variable, if true then carry on else exception.
I don't wish to implement standalone timers event for that...., as there are many methods in which i need to implement this.
Hassles of Async programming!!!.

Any help please!!!
Thank You.