I am starting using an external library (SDK) that requires a context(SynchronizationContext) at initialization, so my first approach on testing it was by writing a simple console app, but, when I try to use SynchronizationContext.Current
is null.
string key = ConfigurationManager.AppSettings[Constants.KEY];
if (DLL.Init(key, SynchronizationContext.Current))
{
Console.WriteLine($"{DLL.IsInitialized()} Press enter to close...");
Console.ReadLine();
}
Console.WriteLine($"{DLL.IsInitialized()} Press enter to close...");
Console.ReadLine();
Would you mind helping me to understand the usage of ``SynchronizationContext``` and why is not initialized at the console app?
Update This question could be similar to -> Why the default SynchronizationContext is not captured in a Console App?, but, I do not understand, why a console app needs a custom context?