/// <summary> /// Update the internal XML of the Viewer window. /// </summary> private async Task RefreshCharacterXml() { using (CursorWait.New(this, true)) { await Task.WhenAll(this.DoThreadSafeAsync(() => { tsPrintPreview.Enabled = false; tsSaveAsHtml.Enabled = false; }), cmdPrint.DoThreadSafeAsync(x => x.Enabled = false), cmdSaveAsPdf.DoThreadSafeAsync(x => x.Enabled = false)); Character[] aobjCharacters = await _lstCharacters.ToArrayAsync(); _objCharacterXml = aobjCharacters.Length > 0 ? await CommonFunctions.GenerateCharactersExportXml(_objPrintCulture, _strPrintLanguage, _objRefresherCancellationTokenSource.Token, aobjCharacters) : null; await this.DoThreadSafeAsync(() => tsSaveAsXml.Enabled = _objCharacterXml != null); if (_objRefresherCancellationTokenSource.IsCancellationRequested) { return; } await RefreshSheet(); } }
/// <summary> /// Update the internal XML of the Viewer window. /// </summary> private async Task RefreshCharacterXml(CancellationToken token = default) { token.ThrowIfCancellationRequested(); CursorWait objCursorWait = await CursorWait.NewAsync(this, true, token); try { await Task.WhenAll(this.DoThreadSafeAsync(() => { tsPrintPreview.Enabled = false; tsSaveAsHtml.Enabled = false; }, token), cmdPrint.DoThreadSafeAsync(x => x.Enabled = false, token), cmdSaveAsPdf.DoThreadSafeAsync(x => x.Enabled = false, token)); token.ThrowIfCancellationRequested(); Character[] aobjCharacters = await _lstCharacters.ToArrayAsync(); token.ThrowIfCancellationRequested(); _objCharacterXml = aobjCharacters.Length > 0 ? await CommonFunctions.GenerateCharactersExportXml(_objPrintCulture, _strPrintLanguage, _objRefresherCancellationTokenSource.Token, aobjCharacters) : null; token.ThrowIfCancellationRequested(); await this.DoThreadSafeAsync(() => tsSaveAsXml.Enabled = _objCharacterXml != null, token); token.ThrowIfCancellationRequested(); await RefreshSheet(token); } finally { await objCursorWait.DisposeAsync(); } }