flush

C# flushing StreamWriter and a MemoryStream

无人久伴 提交于 2020-01-24 08:01:23
问题 I use the following snippet of code, and I'm unsure whether I need to call the Flush methods (once on StreamWriter , once on MemoryStream ): //converts an xsd object to the corresponding xml string, using the UTF8 encoding public string Serialize(T t) { using (var memoryStream = new MemoryStream()) { var encoding = new UTF8Encoding(false); using (var writer = new StreamWriter(memoryStream, encoding)) { var serializer = new XmlSerializer(typeof (T)); serializer.Serialize(writer, t); writer

Why does Hibernate only Auto-Flush inside a transaction?

*爱你&永不变心* 提交于 2020-01-23 07:08:50
问题 What is the rationale behind this behavior? If for some reason I execute two suitable operations outside a transaction (not recommended, I know!) and I've configured Hibernate to auto-flush, I would expect it to auto-flush if the second operation is one that should trigger an auto-flush (like list , iterate , or executeUpdate ). That's exactly what would happen, if not for the explicit check on the second line of the autoFlushIfRequried method: protected boolean autoFlushIfRequired(Set

Why does using std::endl with ostringstream affect output speed?

只谈情不闲聊 提交于 2020-01-22 14:04:06
问题 I'm timing the difference between various ways to print text to standard output. I'm testing cout , printf , and ostringstream using both \n and std::endl . I expected std::endl to make a difference with cout (and it did), but I didn't expect it to slow down output with ostringstream . I thought using std::endl would just write a \n to the stream and it would still only get flushed once. What's going on here? Here's all my code: // cout.cpp #include <iostream> using namespace std; int main()

python print function in real time

回眸只為那壹抹淺笑 提交于 2020-01-19 05:41:07
问题 I recently switched OS and am using a newer Python (2.7). On my old system, I used to be able to print instantaneously. For instance, suppose I had a computationally intense for loop: for i in range(10): huge calculation print i then as the code completed each iteration, it would print i However, on my current system, python seems to cache the stdout so that the terminal is blank for several minutes, after which it prints: 1 2 3 in short succession. Then, after a few more minutes, it prints:

How do I solve this problem with the output being unable to get the statement of the input(myflush) in coding “Random Number Guessing” in C

眉间皱痕 提交于 2020-01-16 08:59:18
问题 I tried going beyond just guessing random numbers. Basically, the program should be made to show like this : insert a number : 70 bigger than 0 smaller than 70. insert a number : 35 bigger than 35 smaller than 70. insert a number : 55 bigger than 55 smaller than 70. insert a number : 60 bigger than 55 smaller than 60. insert a number : 57 You got it right on your 5th try! I had some problems, but already through brilliant people in stackoverflow, I am able to get all the results I wish, but

Why is CGLFlushDrawable so slow? (I am using VBOs)

好久不见. 提交于 2020-01-15 10:40:24
问题 My application details: Running on : Macbook pro with 4GB RAM, ATI Radeon X1600 with 128MB VRAM, Opengl version: 2.1 ATI-7.0.52 Using vertical sync (via CVDisplay) : YES Programming Language: Lisp (Lispworks) with FFI to Opengl Pixel Format information ns-open-gl-pfa-depth-size 32 ns-open-gl-pfa-sample-buffers 1 ns-open-gl-pfa-samples 6 ns-open-gl-pfa-accelerated 1 ns-open-gl-pfa-no-recovery 1 ns-open-gl-pfa-backing-store 0 ns-open-gl-pfa-virtual-screen-count 1 [1 = YES, 0 = NO] for boolean

Outputting exec() ping result progressively

有些话、适合烂在心里 提交于 2020-01-14 03:02:13
问题 I'm trying to write a function that pings a few hundred addresses and returns their values (milliseconds). So far I've achieved the initial idea which is to ping and get the result but the problem arises when using the same code for hundreds of addresses, the PHP page stalls until it either times out or reaches the last ping command. I would be glad if I could get some suggestions to output the results progressively, here is my current code: <?php // "for" loop added according to suggestion

StreamWriter automatically flushing buffer when given large messages

一个人想着一个人 提交于 2020-01-11 10:23:50
问题 Overview I have a Client-Server whereby I have the streamWriter.WriteLine(messageToClient); on the server sending large messages. The streamReader.ReadLine(); on the client is reading the 2000 length messages fine. The issue here is the streamWriter.Flush() has no affect on the larger messages, because what I am aiming for is the server to be able to switch between the buffers flushing directly (having a fluid server message output) and not (the server response would be jumbled together until

How to clear console in Java - Eclipse

社会主义新天地 提交于 2020-01-11 06:24:54
问题 How to clear the console after a few statements have been executed/printed in Eclipse. I have used flush() but didn't work though. Just posting the sample code. System.out.println("execute "); System.out.println("these set of lines "); System.out.println("first"); Thread.sleep(2000); // just to see the printed statements in the console System.out.flush(); // it is not clearing the above statements 回答1: System.out is a Stream , it makes no sense to clear a stream. Eclipse's Console is a view

When do browsers start to render partially transmitted HTML?

Deadly 提交于 2020-01-11 05:00:35
问题 I have a long-running report and want to show a wait-spinner to the user while it's generating. I have made this work already but am not sure I'm doing it the best or right way. This is using ColdFusion but it could be any language I guess. At the top of the page, I have some Javascript (jQuery) that shows a wait-spinner plus there's a documentReady handler where I take the spinner down. I flush the output ( if it matters) and then the rest of the code works on the report contents. This wasn