c# - What does it mean for a method to be asynchronous? -
what asynchronous method. think know, keep confusing parallelism. i'm not sure difference between asynchronous method , parallelism is.
also difference between using threading classes , asynchronous classes?
edit
some code demonstrating difference between async, threading , parallelism useful.
what asynchronous methods?
asynchronous methods come discussion when talking potentially lengthy operations. typically need such operation complete in order meaningfully continue program execution, don't want "pause" until operation completes (because pausing might mean e.g. ui stops responding, undesirable).
an asynchronous method 1 call start lengthy operation. method should needs start operation , return "very quickly" there no processing delays.
async methods typically return token caller can use query if operation has completed yet , result was. in cases take callback (delegate) argument; when operation complete callback invoked signal caller results ready , pass them back. this commonly used callback signature, although of course in general callback can anything.
so run lengthy operation?
i said above async method starts length operation, "start" mean in context? since method returns immediately, actual work being done?
in general case execution thread needs keep watch on process. since it's not thread called async method pauses, does? answer is, thread picked purpose managed thread pool.
what's connection threading?
in context interpretation of "threading" explicitly spin thread of own , delegate execute task in question synchronously. thread block time , presumably signal "main" thread (which free continue executing) when operation complete.
this designated worker thread might pulled out of thread pool (beware: doing lengthy processing in thread pool thread not recommended!) or might 1 you started purpose.
Comments
Post a Comment