none
why control class has SynchronizationContext ? RRS feed

  • Question

  • Hi,

    I am looking multithread part , I heard few buzz words say SynchronizationContext, ExecutionContext and CallContext. what this class ?

    Can any one tell me what this all and why control class only can create SynchronizationContext ? and what else context classes are there ?

    Note: If some one gives me a diagram structure of a exe(Process) could be appreciatable .Let say first os , next process then .net BCL then AppDomain etc...

    Wednesday, January 14, 2015 11:00 AM

Answers

  • >>why Console Application didn't have SynchronizationContext ?

    Because there is no framework class code nor threading model that initializes a SynchronizationContext for you in a console application.

    In a Windows Forms application the first Form creates one as clearly explained on the second link I gave you and in a WPF application the SynchronizationContext gets initialized when you create the System.Windows.Application object. If you set a breakpoint in the Main method of a Windows Form or a WPF application SynchronizationContext.Current also returns null just like in a console application.


    Also, as the MSDN Magazine article says: "By convention, if a thread’s current SynchronizationContext is null, then it implicitly has a default SynchronizationContext.".

    "By default, all threads in console applications and Windows Services only have the default SynchronizationContext."

    Please refer to the following links for more information:
    https://social.msdn.microsoft.com/Forums/en-US/026663c0-5477-4a5b-bc33-983247463b6d/console-apps?forum=async
    http://www.wintellect.com/blogs/jeffreyr/integrating-your-application-s-threading-model-with-the-asynchronous-programming-model

    And please remember to mark all helpful posts as answer to close the thread and start a new one if you have another question.

     

     

    Friday, January 16, 2015 10:25 AM

All replies