Exemplo n.º 1
0
        /// <summary>
        /// Invokes the delegate associated with this binding and dispatches an event notification to the
        /// appropriate component.
        /// </summary>
        /// <param name="arg">The argument.</param>
        /// <returns>A <see cref="Task"/> which completes asynchronously once event processing has completed.</returns>
        public Task InvokeAsync(TValue?arg)
        {
            if (Receiver == null)
            {
                return(EventCallbackWorkItem.InvokeAsync <TValue?>(Delegate, arg));
            }

            return(Receiver.HandleEventAsync(new EventCallbackWorkItem(Delegate), arg));
        }
Exemplo n.º 2
0
        // This is a temporary polyfill for these old-style bind methods until they can be removed.
        // This doesn't do proper error handling (usage is fire-and-forget).
        private static Task DispatchEventAsync(object component, EventCallbackWorkItem callback, object arg)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (component is IHandleEvent handler)
            {
                return(handler.HandleEventAsync(callback, arg));
            }

            return(callback.InvokeAsync(arg));
        }
Exemplo n.º 3
0
        Task IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, object arg)
        {
            var task            = callback.InvokeAsync(arg);
            var shouldAwaitTask = task.Status != TaskStatus.RanToCompletion &&
                                  task.Status != TaskStatus.Canceled;

            // After each event, we synchronously re-render (unless !ShouldRender())
            // This just saves the developer the trouble of putting "StateHasChanged();"
            // at the end of every event callback.
            StateHasChanged();

            return(shouldAwaitTask ?
                   CallStateHasChangedOnAsyncCompletion(task) :
                   Task.CompletedTask);
        }
Exemplo n.º 4
0
 public Task HandleEventAsync(EventCallbackWorkItem item, object arg)
 {
     Count++;
     return(item.InvokeAsync(arg));
 }
Exemplo n.º 5
0
 public Task HandleEventAsync(EventCallbackWorkItem item, object arg)
 {
     throw new NotImplementedException();
 }