Skip to content

Commit

Permalink
Merge pull request #2667 from wpfcontrib/fixup-environment_userintera…
Browse files Browse the repository at this point in the history
…ctive-usage

Fixup Environment.UserInteractive uses to workaround dotnet/runtime#32929
  • Loading branch information
rladuca authored Feb 27, 2020
2 parents 687a02f + 2c3d0b3 commit efb8416
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ private static int FindNextPrime(int number)
/// when inside a SCM service.
/// </remarks>
internal static bool ShouldRenderEvenWhenNoDisplayDevicesAreAvailable { get; } =
!Environment.UserInteractive ? // IF DisplayDevicesNotAvailable && IsNonInteractiveWindowStation/IsService...
!CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation : // THEN render by default, allow ShouldNotRender AppContext override
// Temporary workaround for https://github.com/dotnet/runtime/issues/32929
// Do not merge into master
// !Environment.UserInteractive ? // IF DisplayDevicesNotAvailable && IsNonInteractiveWindowStation/IsService...
// !CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation : // THEN render by default, allow ShouldNotRender AppContext override
CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable; // ELSE do not render by default, allow ShouldRender AppContext override


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ public virtual Nullable<bool> ShowDialog()

// Don't allow file dialogs to be shown if not in interactive mode
// (for example, if we're running as a service)
if (!Environment.UserInteractive)
{
throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive));
}

// Temporary workaround for https://github.com/dotnet/runtime/issues/32929
// Do not merge into master
// if (!Environment.UserInteractive)
// {
// throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive));
// }

// Call GetActiveWindow to retrieve the window handle to the active window
// attached to the calling thread's message queue. We'll set the owner of
Expand Down Expand Up @@ -149,10 +152,13 @@ public Nullable<bool> ShowDialog(Window owner)

// Don't allow file dialogs to be shown if not in interactive mode
// (for example, if we're running as a service)
if (!Environment.UserInteractive)
{
throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive));
}

// Temporary workaround for https://github.com/dotnet/runtime/issues/32929
// Do not merge into master
// if (!Environment.UserInteractive)
// {
// throw new InvalidOperationException(SR.Get(SRID.CantShowModalOnNonInteractive));
// }

// Get the handle of the owner window using WindowInteropHelper.
IntPtr hwndOwner = (new WindowInteropHelper(owner)).CriticalHandle;
Expand Down

0 comments on commit efb8416

Please sign in to comment.