Thank you for idea. I have tested it and found it not useful. I work on ServerPrerendered Blazor application. In different situation delay of toast show should be different. Thus I should choose maximal delay.
If I use syncronous method to make Delay it stops another rendering. If I try to make the method of creating toast asyncronous - it followed by conflict between few threads, which could not be solved by simple InvokeAsync just before Toast.Show().
Your toast component has IsRendered property and I decided to use it. I do the next:
SfToast MessageToast;
Queue<ToastModel> Queue = new Queue<ToastModel>();
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
if (firstRender)
{
while (Queue.Count > 0)
{
MessageToast.Show(Queue.Dequeue());
}
}
}
private void ShowToast(string Message, ToastLevel Level, int VisibleTimeOut = 0)
{
ToastModel toast = new ToastModel { ... };
// other toast details depending on received content
if (!MessageToast.IsRendered)
Queue.Enqueue(toast);
else
{
MessageToast.Show(toast);
}
}
I am not sure that I do the right way because it looks like AfterFirstRender fires before IsRendered is triggered. If so, please, show me the write way to catch IsRendered changing event.
By the way, I found that if toast has fixed properties inside it, is it not possible to change them and to show toast with this new porperties. First values are shown each time. I should use ToastModel only to change toast. Moreover, fixed and model properties could not be used together, in this case fixed values will be owerritten by default values from model. It is opposite to Dialog and could not be obvious after it.