Re: Thread with timeout, pls help
From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 01/21/05
- Next message: Mike D: "Re: DropDownList"
- Previous message: Willy Denoyette [MVP]: "Re: PLS HELP - Unable to close a "stuck" thread"
- In reply to: Dan Pavel: "Thread with timeout, pls help"
- Next in thread: Dan Pavel: "Re: Thread with timeout, pls help"
- Reply: Dan Pavel: "Re: Thread with timeout, pls help"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 21 Jan 2005 15:50:29 -0500
Hi,
It does depend of the lib functionality. Maybe it does provide a property
or a constructor overload where you can set the timeout.
If not you are pretty much without much else to do.
The only other possible solution I can think of is create a thread to do the
Refresh while the main thread sleep for two seconds, then check if the
worker thread is still blocked ( you may use a flag for this) and if it is
do accordingly.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dan Pavel" <myalternativmail@yahoo.com> wrote in message
news:%23IQAIJ9$EHA.2600@TK2MSFTNGP09.phx.gbl...
>
>
> Hi, I am kind of new in programming and I have a problem.
> I am getting some values through SNMP and when I don't get an answer
> from remote host, my refresh function keeps waiting. I cannot modify the
> function because is from a .dll. I need some timeout thread who can stop
> after 2 seconds if I don't get any answer from the remote host.
>
> Here it is:
>
> private string mib_read(string host, uint[] mib)
> {
> {
> string val;
> ManagerSession sess = new ManagerSession(host,"public");
> ManagerItem mi = new ManagerItem(sess,mib);
> try
> {
> logText("before [read] refresh...");
> mi.Refresh(); //<-------------The crash !!! logText("after [read]
> refresh...");
> val=mi.Value.ToString();
> }
> catch (Exception e)
> {
> logText("Refresh Failed........."+e);
> val="NULL";
> }
> return val;
> }
> }
>
> Please help.
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
- Next message: Mike D: "Re: DropDownList"
- Previous message: Willy Denoyette [MVP]: "Re: PLS HELP - Unable to close a "stuck" thread"
- In reply to: Dan Pavel: "Thread with timeout, pls help"
- Next in thread: Dan Pavel: "Re: Thread with timeout, pls help"
- Reply: Dan Pavel: "Re: Thread with timeout, pls help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|