Calling from inside a Thread is a problematic

I have a number of dialogues which I call from async threads, and this does not works.
For instance :

 protected override void OnAfterRender( bool firstRender )
    {
        base.OnAfterRender( firstRender );

        if( firstRender )
        {

            var isEmbedTask = jSRuntime.InvokeAsync<string>( "getEmbedInjection" );
            isEmbedTask.ConfigureAwait( false ).GetAwaiter().OnCompleted( () =>
            {
                var o = isEmbedTask.Result;
                isEmbed = string.IsNullOrWhiteSpace( o ) == false;

                if( isEmbed )
                {                    
                    loginDialog.Hide();                  
                    dialogLoingVisibility = false;
                }
                else
                {
                    dialogLoingVisibility = true;
                    loginDialog.Show();                                      
                }
            } );


this will not work until I click somewhere in the window, then the new visibility will be applied.

2 Replies 1 reply marked as answer

YO Yordan October 20, 2020 07:03 AM UTC

Found the solution a few minutes later. Clearly a my mistake.

- I need to use InvokeAsync( () =>
on each call to the main thread components from async threads.

Marked as answer

IS Indrajith Srinivasan Syncfusion Team October 21, 2020 10:53 AM UTC

Hi Yordan, 
 
Good day to you, 
 
We are glad that your found a solution for the reported issue. Please get back to us if you need any further assistance, 
 
Regards, 
Indrajith 


Loader.
Up arrow icon