示例#1
0
        /// <summary>
        /// Update the internal XML of the Viewer window.
        /// </summary>
        private async Task RefreshCharacterXml()
        {
            using (new CursorWait(this, true))
            {
                await Task.WhenAll(this.DoThreadSafeAsync(() =>
                {
                    tsPrintPreview.Enabled = false;
                    tsSaveAsHtml.Enabled = false;
                }),
                                   cmdPrint.DoThreadSafeAsync(() => cmdPrint.Enabled         = false),
                                   cmdSaveAsPdf.DoThreadSafeAsync(() => cmdSaveAsPdf.Enabled = false));

                _objCharacterXml = _lstCharacters.Count > 0
                    ? await CommonFunctions.GenerateCharactersExportXml(_objPrintCulture, _strPrintLanguage,
                                                                        _objRefresherCancellationTokenSource.Token,
                                                                        _lstCharacters.ToArray())
                    : null;

                await this.DoThreadSafeAsync(() => tsSaveAsXml.Enabled = _objCharacterXml != null);

                if (_objRefresherCancellationTokenSource.IsCancellationRequested)
                {
                    return;
                }
                await RefreshSheet();
            }
        }
示例#2
0
 /// <summary>
 /// Update the internal XML of the Viewer window.
 /// </summary>
 private void AsyncRefresh(object sender, DoWorkEventArgs e)
 {
     _blnQueueRefresherRun = false;
     if (_lstCharacters.Count <= 0)
     {
         _objCharacterXml = null;
         return;
     }
     _objCharacterXml = CommonFunctions.GenerateCharactersExportXml(_objPrintCulture, _strPrintLanguage,
                                                                    _objRefresherCancellationTokenSource.Token, _lstCharacters.ToArray());
 }
        /// <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();
            }
        }