Exemple #1
1
        private async Task ReceiveEnvelopeAsync(Envelope envelope, Dispatcher dispatcher)
        {
            var envelopeViewModel = new EnvelopeViewModel();
            envelopeViewModel.Envelope = envelope;
            envelopeViewModel.Direction = DataOperation.Receive;

            await await dispatcher.InvokeAsync(async () => 
                {
                    this.Envelopes.Add(envelopeViewModel);

                    foreach (var macro in Macros.Where(m => m.IsActive))
                    {
                        await macro.Macro.ProcessAsync(envelopeViewModel, this);
                    }
                });
        }
        /// <summary>
        /// Starts a new delay execution asynchronously.
        /// The previous waiting can be canceled.
        /// </summary>
        /// <param name="action">The action to execute with delay.</param>
        /// <param name="delayTime">Time to wait before executing the action.</param>
        public DispatcherOperation StartAsync(Action action, TimeSpan delayTime)
#endif
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

#if NICENIS_UWP
            return(TheWindow.Current.Dispatcher.RunAsync(_delegatePriority, () => StartImpl(action, delayTime)));
#else
            return(_dispatcher.InvokeAsync(() => StartImpl(action, delayTime), _delegatePriority));
#endif
        }
 /// <summary>
 /// 指定したURLからダウンロードした画像データを使用して、指定したDispatcher上でBitmapImageを生成します
 /// </summary>
 /// <param name="url">画像URL</param>
 /// <param name="dispatcherForBitmapCreation">BitmapImageを生成するDispatcher</param>
 /// <returns>BitmapImage</returns>
 public static async Task<BitmapImage> DownloadImageAsync(string url, Dispatcher dispatcherForBitmapCreation)
 {
     var bytes = await DownLoadImageBytesAsync(url).ConfigureAwait(false);
     return await dispatcherForBitmapCreation.InvokeAsync(() => CreateBitmap(bytes));
 }
 public void FireLoaded()
 {
     _clientThreadDispatcher.InvokeAsync(() =>
                                         _parent.FireLoaded());
 }