You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Powershell freezes when using Invoke-GraphRequest and WPF #390
I have come across a problem where if I trigger Invoke-GraphRequest from a WPF button the command freezes.
This seems to affect at least getting a list of onenote section groups or sections or pages
I have tried debugging in VSCode setting a breakpoint on the line that runs Invoke-GraphRequest and it also does the same thing.
Below created an example using minimal code.
I have also included Get-MgGroupOnenoteNotebookSectionGroup which works fine and returns the correct result.
Please enter the top 3 variables for testing (removed as they were specific to my tenant)
#a group id from graph which could be retrieve using Get-MgGroup
$groupid = ""
#a notebook id from graph which could be retrieve using Get-MgGroupOnenoteNotebook
$notebookid = ""
#a section group uri from (Get-MgGroupOnenoteNotebook -groupid $groupid -notebookid $notebookid).sectionGroupsUrl
$sectiongroupsuri = ""
#Make sure we are authenticated to graph
Connect-Graph -scope @("Notes.ReadWrite.All","Group.Read.All","Sites.Read.All") | out-null
#build ui
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="Get-MgGroupOnenoteNotebookSectionGroup" HorizontalAlignment="Left" Margin="10,10,10,10" VerticalAlignment="Top"/>
<Button Name="button2" 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 (Get-MgGroupOnenoteNotebookSectionGroup -GroupId $groupid -NotebookId $notebookid | out-string)
})
$button2 = $window.FindName("button2")
$button2.Add_Click( {
write-host (Invoke-GraphRequest -uri $sectiongroupsuri | out-string)
})
$window.ShowDialog()
I can confirm the issue persists in v1.0.1. Note I am trying from powershell 5.1. I have tested in both VSCode and directly running the script and both have the same issue
Activity
TobyHawkes commentedon Oct 1, 2020
I can confirm the issue persists in v1.0.1. Note I am trying from powershell 5.1. I have tested in both VSCode and directly running the script and both have the same issue
Use asynccommandruntime to handle async calls.
Handle UI Freezes when IMGR is called from WPF (#439)
TobyHawkes commentedon Dec 8, 2020
tested - all works now on v1.2.0, thanks for the update!