timeout

What is the difference between Thread.Sleep(timeout) and ManualResetEvent.Wait(timeout)?

冷暖自知 提交于 2019-12-17 22:50:48
问题 Both Thread.Sleep(timeout) and resetEvent.Wait(timeout) cause execution to pause for at least timeout milliseconds, so is there a difference between them? I know that Thread.Sleep causes the thread to give up the remainder of its time slice, thus possibly resulting in a sleep that lasts far longer than asked for. Does the Wait(timeout) method of a ManualResetEvent object have the same problem? Edit : I'm aware that a ManualResetEvent's main point is to be signaled from another thread - right

c# detecting tcp disconnect

大憨熊 提交于 2019-12-17 22:25:17
问题 I have two simple applications: A Server application that waits on a specific tcp port for a client to connect. Then listens to what he says, send back some feedback and DISCONNECT that client. A Form application that connects to the server application, then says something, then wait for the feedback and disconnect from the server, then show the feedback in the form. Though the server application seems to behave correctly (I have tested it with Telnet and I see the feedback and I see the

Call getPage from htmlunit WebClient with JavaScript disabled and setTimeout set to 10000 waits forever

萝らか妹 提交于 2019-12-17 20:26:12
问题 I'm having problems with Htmlunit, I disabled JavaScript and set timeout to 10000 before calling getpage, I expected an exception after timeout but htmlunit waits forever. After some search I realized someone in 2009 had the same problem (Connection timeout not working), he was complaining about "Connection timeout not working" and about some values in timeout not working but until now in 2011 didn't get any answer. Someone here was asking about what exception is thrown but I think it doesn't

How to timeout a read on Java Socket?

时间秒杀一切 提交于 2019-12-17 20:17:00
问题 I'm trying to read items from a socket and I notice that if there is nothing on the stream of the socket it will stay at the read and back up my application. I wanted to know if there was a way to set a read timeout or terminate the connection after a certain amount of time of nothing in the socket. 回答1: If you write Java, learning to navigate the API documentation is helpful. In the case of a socket read, you can set the timeout option. 回答2: If this socket was created through a URLConnection

Timeout behavior of different browsers?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 20:00:20
问题 I am writing an on line chat room based on AJAX/COMET. My design is: Request ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ----------------- wait -------------------------> send dump data ------ something happened, get response. Another request ..... .... As you see, the server hold

How to set the timeout period on a JPA EntityManager query

我与影子孤独终老i 提交于 2019-12-17 19:50:16
问题 I'm currently getting connection timeout errors from my EntityManager queries. Is it possible to set a timeout for these? persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="CallPU" transaction-type="RESOURCE_LOCAL">

C# Stream.Read with timeout

徘徊边缘 提交于 2019-12-17 19:33:42
问题 I have this streamreader: Boolean read = false; while (wline!="exit") { while (!read || streamReader.Peek() >= 0) { read = true; Console.Write((char)streamReader.Read()); } wline = Console.ReadLine(); streamWriter.Write(wline+"\r\n"); streamWriter.Flush(); } How to set a timeout for Read() method? thanks 回答1: If this is System.IO.StreamReader , then set it on the BaseStream : streamReader.BaseStream.ReadTimeout = 2000; //milliseconds, so 2 seconds 回答2: You need to deal with the underlying

KSOAP never timeout

回眸只為那壹抹淺笑 提交于 2019-12-17 19:29:26
问题 I'm using ksoap2 2.5.4 (on Android 2.2) which supports timeout. I'm using Apache 2.2.16 to handle my requests. Everything works fine, but when I shutdown my Apache (or disconnect remote PC on which Apache is running) the call never times out. I'm using separate thread to call my WS and this thread stop working/responding/stalls for about 2 minutes in this case. int MSG_TIMEOUT = 15000; HttpTransportSE httpTransport; SoapSerializationEnvelope envelope = new SoapSerializationEnvelope

Add delay to javascript method that returns promise

霸气de小男生 提交于 2019-12-17 19:21:38
问题 I'm currently trying to learn Angular 2, typescript, promises, etc. I've setup a small app for developer tools and a service that just returns hard-coded data. This is to be used for testing purposes only. I'd like to add short timeout on the service method to simulate server lag for testing some of my controls, but I can't find the correct syntax to do so. How can I add a 5 second delay to my service call? Developer Tools Service @Injectable() export class DeveloperService { getExampleData()

How can I change the table adapter's command timeout

拥有回忆 提交于 2019-12-17 19:18:27
问题 I'm using Visual Studio 2008 with C#. I have a .xsd file and it has a table adapter. I want to change the table adapter's command timeout. Thanks for your help. 回答1: I have investigated this issue a bit today and come up with the following solution based on a few sources. The idea is to create a base class for the table adapter too inherit which increases the timeout for all commands in the table adapter without having to rewrite too much existing code. It has to use reflection since the