Why foreach do not print value during every single Insert request in SQL?

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 15 04:12:00 PST 2015


On Thursday, 15 January 2015 at 12:05:24 UTC, Suliman wrote:
> 		void IMGsInsert(string [] fullimgurl)
> 		{
> 			foreach (url; fullimgurl)
> 			{
> 				string sqlinsert = (sqlrequest)
> 				writeln(sqlinsert);
> 				write("|");
> 				auto rs = stmt.executeUpdate(sqlinsert);
> 			}
>
> 		}
>
> I expect nice progress indicator "|" which move forward after 
> every Insert request.
> Like:
> ||||
> and so on.
>
> The problem that App wait some time and only in prints a heap 
> of "|". Why?

Terminal output is line-buffered by default. To display an 
incomplete line to the user, add "stdout.flush()" after your 
"write" call.


More information about the Digitalmars-d-learn mailing list