Skip to content

Handle UI Freezes when IMGR is called from WPF - #439

Merged
George (georgend) merged 14 commits into
devfrom
bugfixes/powershellFreezes
Nov 25, 2020
Merged

George (georgend) merged 14 commits into
devfrom
bugfixes/powershellFreezes

Conversation

@georgend

@georgend George (georgend) commented Oct 22, 2020 •

Copy link
Copy Markdown
Contributor

Use asynccommandruntime to handle async calls.
Fix double formatted resource strings.

Testing
Client was using the script references in issue #390
Local testing using client script shows the freezes no longer occur.

Fixes #436
Fixes #390

@peombwa Peter Ombwa (peombwa) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the UI freeze also happens with Connect-MgGraph when called with -ForceRefresh. Consider using NoSynchronizationContext with Connect-MgGraph as well.

Here is a repro of the same :

Add-Type -AssemblyName PresentationFramework

[xml]$xaml = @"
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    Title="Window" Height="200" Width="300">
    <Grid Background="#FFECECEC">
    <Button Name="button1" Content="Connect-MgGraph" HorizontalAlignment="Left" Margin="10,10,10,10" VerticalAlignment="Top"/>
	<Button Name="button2" Content="Connect-MgGraph -ForceRefresh" HorizontalAlignment="Left" Margin="10,30,10,10" VerticalAlignment="Top"/>
    <Button Name="button3" Content="Invoke-GraphRequest" HorizontalAlignment="Left" Margin="10,50,10,10" VerticalAlignment="Top"/>
    </Grid>
    </Window>
"@

$reader = (New-Object System.Xml.XmlNodeReader $xaml)

$window = [Windows.Markup.XamlReader]::Load($reader)

$button1 = $window.FindName("button1")
$button1.Add_Click( {
    write-host (Connect-MgGraph | out-string)
})

$button2 = $window.FindName("button2")
$button2.Add_Click( {
    write-host (Connect-MgGraph -ForceRefresh | out-string)
})

$button3 = $window.FindName("button3")
$button3.Add_Click( {
    write-host (Invoke-GraphRequest -uri "https://graph.microsoft.com/v1.0/users" | out-string)
})

$window.ShowDialog()

@darrelmiller Darrel (darrelmiller) modified the milestones: 1.1.0, 1.2.0 Nov 11, 2020
Minor cleanup
@georgend
George (georgend) merged commit 2da2646 into dev Nov 25, 2020
@peombwa
Peter Ombwa (peombwa) deleted the bugfixes/powershellFreezes branch December 11, 2020 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double Formatted Resource Strings in InvokeMgGraphRequest.cs Powershell freezes when using Invoke-GraphRequest and WPF

3 participants