Completed
Last Updated: 08 Jan 2021 13:03 by ADMIN
Release 2.7.0
Boguslaw
Created on: 09 Dec 2019 13:58
Category: Window
Type: Bug Report
2
Telerik Window is causing following error: The current thread is not associated with the Dispatcher

I'm working on blazor server side application.
After update Telerik.UI.for.Blazor from 2.1 to 2.5 (before I updated .net core from 3.0 to 3.1) it shows following error:
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.

I investigated that it's cause by Telerik window.
The error occurs when window is on start page or when the page is refreshed.
Below code for Index.razor which cause the error:

 

@page "/"
 
<TelerikWindow @bind-Visible="@WindowIsVisible">
    <WindowTitle>
        <strong>The Title</strong>
    </WindowTitle>
    <WindowContent>
        This is my window <strong>popup</strong> content.
    </WindowContent>
    <WindowActions>
        <WindowAction Name="Minimize"></WindowAction>
        <WindowAction Name="Maximize"></WindowAction>
        <WindowAction Name="Close"></WindowAction>
    </WindowActions>
</TelerikWindow>
 
<TelerikButton OnClick="@( () => WindowIsVisible = !WindowIsVisible )">Toggle window</TelerikButton>
 
@code {
    bool WindowIsVisible { get; set; } = false;
}

Thanks
5 comments
ADMIN
Svetoslav Dimitrov
Posted on: 08 Jan 2021 13:03

Hello Victor,

Thank you for sharing your experience on the topic. I would like to provide some more information on the different Render modes for Blazor:

  • Static - renders just HTML in the browser. As the mode's name suggests interactive behavior would not be supported, for example, button clicks would not be applicable.
  • Server - the SignalR connection provides an interactive HTML. The downside of this is that the initial load (the time between landing on the page and actually seeing the content) will be higher depending on the latency.
  • ServerPrerendered - it is a mix of both render modes. It will send plain HTML to improve the initial load time (the user sees some static content) and at some point, the SignalR connection carries the actual events which make the page interactive.

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Victor
Posted on: 04 Jan 2021 20:00

I'm seeing the same and as a workaround I have changed the render-mode for the app in my _Host.cshtml from "ServerPrerendered"  to "Server"

I'm using .net 5.0 and Telerik.UI.for.Blazor 2.20.0

ADMIN
Svetoslav Dimitrov
Posted on: 28 Oct 2020 10:20

Hello John,

As an attached file to this post, I have added a demo application, which references Telerik UI for Blazor 2.18.0, which at the time of writing this is our latest release. When I run it locally it behaves as expected and after a page refresh, the error you described is not reproducible (both in the browser console and the Output window for the ASP.NET Core Web Server). If the attached application runs as expected for you too, you could compare it against your own to see if any differences cause the behavior. If this does not help I would encourage you to open a support ticket so we can discuss the topic in more depth. 

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files:
John
Posted on: 22 Oct 2020 13:35

I get a similar error with the grid, works fine unless I hit F5 then...

InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.

 

 

 <TelerikGrid Data=@GridData @ref="@Grid"
                 Pageable=true PageSize=@PageSize
                 Groupable="true"
                 Sortable="true"
                 FilterMode="GridFilterMode.FilterMenu"
                 Resizable="true"
                 Reorderable="true"
                 SelectionMode="GridSelectionMode.Single"
                 Navigable="true"
                 OnDelete="@DeleteHandler">
        <GridToolBar>
            <GridCommandButton Command="AddDTO" OnClick="@AddNewDTO" Icon="add">Add Position</GridCommandButton>
            <TelerikCheckBox Id="chkBoxOnlyEssential" @bind-Value="@IsOnlyEssential" OnChange="@onEssentialFilterChanged" />
            <label for="chkBoxOnlyEssential" title="Only show positions deemed essential in a furlough situation" class="m-0">Essential Only</label>

            <TelerikCheckBox Id="chkBoxOnlyAuthorized" @bind-Value="@IsOnlyAuthorized" OnChange="@onAuthorizedFilterChanged" />
            <label for="chkBoxOnlyAuthorized" title="Only show positions authorized as compared to the offical complement list" class="m-0">Authorized Only</label>

            <GridSearchBox DebounceDelay="200"></GridSearchBox>
        </GridToolBar>
        <GridColumns>
ADMIN
Marin Bratanov
Posted on: 09 Dec 2019 15:00

Hello Boguslaw,

We are aware of this issue, and it stems from pre-rendering and the two-way binding of the Visible property. We are working on it and it will be fixed in our next release. I moved this thread to the public feedback portal so everyone can Follow the status: https://feedback.telerik.com/blazor/1445426-telerik-window-is-causing-following-error-the-current-thread-is-not-associated-with-the-dispatcher.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor