Re: Thread with timeout, pls help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 01/21/05


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! 


Relevant Pages

  • Re: Problem using sockets
    ... It depends on network latency, ... and the load on the remote host. ... thing a non-blocking connectis going to get you is more control ... connects and then sharing one timeout for both of them. ...
    (comp.unix.programmer)
  • INET Control
    ... Wenn ich mir verbinde gibst nach 60 Sekunden immer einen Timeout. ... Benutzernamen und Passwort, sowie Remote Host sind aber richtig ...
    (microsoft.public.de.vb)
  • ftp site exec && timeout
    ... I'm having now a problem with timeout issue on remote host when ... When I run site exec with in the verbos mode I don't get ... with the messages "Connection closed by remote host". ... solving my problem with connection closed after 1.5 min. ...
    (comp.unix.admin)
  • ftp site exec && timeout
    ... I'm having now a problem with timeout issue on remote host when ... When I run site exec with in the verbos mode I don't get ... with the messages "Connection closed by remote host". ... solving my problem with connection closed after 1.5 min. ...
    (comp.os.linux.misc)