/// <summary> /// Account Picker APIs do not work well with console apps because the console /// window belongs to a different process, which causes a security exception. /// In general, if the parent window handle does not belong to the current process, /// we need to take control over the window handle by injecting a splash screen. /// </summary> private bool UseSplashScreen() { WindowsNativeMethods.GetWindowThreadProcessId(_parentHandle, out uint windowProcessId); uint appProcessId = WindowsNativeMethods.GetCurrentProcessId(); return(appProcessId != windowProcessId); }
/// <summary> /// Account Picker APIs do not work well with console apps because the console /// window belongs to a different process, which causes a security exception. /// In general, if the parent window handle does not belong to the current process, /// we need to take control over the window handle by injecting a splash screen. /// </summary> private bool UseSplashScreen() { if (_synchronizationContext == null) { return(true); } WindowsNativeMethods.GetWindowThreadProcessId(_parentHandle, out uint windowProcessId); uint appProcessId = WindowsNativeMethods.GetCurrentProcessId(); return(appProcessId != windowProcessId); }