.net - Why does Console.ReadKey() block output of Console.WriteLine called in another thread? -
i have simple console app.
static void main(string[] args) { doasync(); console.readkey(); }
here doasync
starts set of task , returns not waiting tasks' completition. each task writes console, ouptut not shown before key pressed.
when use console.readline
works fine.
so i'm curious readkey()
pecularities.
from the documentation console.readkey()
:
the readkey method waits, is, blocks on thread issuing readkey method, until character or function key pressed.
what acquire lock on console.internalsyncobject
, prevents further operations on console.
the console.readline()
method not block thread in way.
reading this article i'm guessing have .net 4.5 installed?
Comments
Post a Comment