using System; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; namespace FastReport.Web.Blazor.Components { public partial class ReportContainer { private void ChangedPageWithoutArgs() { OnUpdate(); } private void ChangedPage(int page) { WebReport.GotoPage(page); ChangedPageWithoutArgs(); } private void Prepare() { WebReport webReport = WebReport; #if DIALOGS webReport.Dialog.CheckDialogs(); #endif if (!webReport.Canceled) { if (webReport.Mode != WebReportMode.Dialog) { if (!webReport.ReportPrepared) { webReport.Report.Prepare(); webReport.SplitReportPagesByTabs(); } } else webReport.Report.PreparePhase1(); } } #if WASM // in wasm we need to prepare report in not main thread protected override async Task OnParametersSetAsync() { Debug.WriteLine($"threadId ReportContainer: {Environment.CurrentManagedThreadId}"); await PrepareAsync(); //await Task.Run(Prepare); WebReport.Container = this; } private async Task PrepareAsync(CancellationToken token = default) { Debug.WriteLine($"threadId ReportContainer: {Environment.CurrentManagedThreadId}"); WebReport webReport = WebReport; #if DIALOGS webReport.Dialog.CheckDialogs(); #endif if (!webReport.Canceled) { if (webReport.Mode != WebReportMode.Dialog) { if (!webReport.ReportPrepared) { await webReport.Report.PrepareAsync(token); webReport.SplitReportPagesByTabs(); } } else webReport.Report.PreparePhase1(); } } #else protected override void OnParametersSet() { Prepare(); WebReport.Container = this; } #endif /// /// Update ReportContainer /// internal void OnUpdate(bool needPrepare = false) { if (needPrepare) Prepare(); StateHasChanged(); } } }