locked
Asynchronous vs Synchronous operation RRS feed

  • Question

  • Hi,

    What is difference between Asynchronous vs Synchronous operation?

    Task class in .NET is a asynchronous operation and Thread class is Synchronous operation?

    Thank you

    Wednesday, January 15, 2014 1:52 PM

Answers

  • You can write a task or thread that is synchronous or asynchronous.  It is synchronous if it runs from beginning to the end with launching any asynchronous events.  It is asynchronous if you launch async events.

    A form Project is always asynchronous because it is driven by events like button events.  A console application can be either asynchronous or synchronous depending if you register events.


    jdweng

    • Marked as answer by Arash_89 Sunday, January 19, 2014 6:09 AM
    Wednesday, January 15, 2014 3:00 PM
  • Task (and its associated classes are wrapper on top of .Net ThreadPool imlementation).

    It makes working with threads (and your multithreaded coding experience) easier.

    Whereas Thread class is a little difficult to work with.

    That's the difference.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    • Marked as answer by Arash_89 Sunday, January 19, 2014 6:09 AM
    Friday, January 17, 2014 10:31 AM

All replies

  • First of all, Task & Thread are means of implementing asynchronous calls and they themselves are neither synchronous or asynchronous.

    Now,

    Synchronous means the call to a function will execute sequentially and the execution flow will only continue after the called function is returned.

    Asynchronous means the call to the function will not wait until it returns. Rather the execution will continue without waiting and the called function will start its own flow of execution(thread).


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    • Proposed as answer by Ramya SJ Friday, January 17, 2014 10:24 AM
    Wednesday, January 15, 2014 2:32 PM
  • You can write a task or thread that is synchronous or asynchronous.  It is synchronous if it runs from beginning to the end with launching any asynchronous events.  It is asynchronous if you launch async events.

    A form Project is always asynchronous because it is driven by events like button events.  A console application can be either asynchronous or synchronous depending if you register events.


    jdweng

    • Marked as answer by Arash_89 Sunday, January 19, 2014 6:09 AM
    Wednesday, January 15, 2014 3:00 PM
  • Thank you,

    Now when we used Task class and Thread class? What is difference between?

    Friday, January 17, 2014 7:40 AM
  • I don't think much.  A task is a main process that spawns threads.  So the threads are the children and the task is the parent.

    jdweng

    Friday, January 17, 2014 9:06 AM
  • Task (and its associated classes are wrapper on top of .Net ThreadPool imlementation).

    It makes working with threads (and your multithreaded coding experience) easier.

    Whereas Thread class is a little difficult to work with.

    That's the difference.


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    • Marked as answer by Arash_89 Sunday, January 19, 2014 6:09 AM
    Friday, January 17, 2014 10:31 AM