/// <summary>
        /// Refreshes the data in the collection. The refresh method is invoked and
        /// this method will replace all the data in the collection with the data coming
        /// back from the refresh method.
        /// </summary>
        /// <returns>Awaitable task</returns>
        public async Task RefreshAsync(bool appendData = false)
        {
            object    refreshParameter = null;
            Exception caughtException  = null;

            isRefreshing = true;

            try
            {
                if (BeforeRefresh != null)
                {
                    refreshParameter = BeforeRefresh.Invoke(this);
                }

                var results = await refreshDataFunc();

                if (results != null)
                {
                    this.Clear();
                    foreach (var item in results)
                    {
                        this.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                caughtException = ex;
            }

            if (caughtException != null)
            {
                if (RefreshFailed != null)
                {
                    await RefreshFailed.Invoke(this, caughtException);
                }
            }
            else if (AfterRefresh != null)
            {
                AfterRefresh.Invoke(this, refreshParameter);
            }

            // Done refresh the world.
            isRefreshing = false;
            OnCollectionChanged(
                new NotifyCollectionChangedEventArgs(
                    NotifyCollectionChangedAction.Reset));
        }
        /// <summary>
        /// Refreshes the data in the collection. The refresh method is invoked and
        /// this method will replace all the data in the collection with the data coming
        /// back from the refresh method.
        /// </summary>
        /// <returns>Awaitable task</returns>
        public async Task RefreshAsync()
        {
            object refreshParameter = null;

            IsRefreshing = true;

            try
            {
                if (BeforeRefresh != null)
                {
                    refreshParameter = BeforeRefresh.Invoke(this);
                }

                var results = await refreshDataFunc();

                if (results != null)
                {
                    using (base.BeginMassUpdate())
                    {
                        if (Merge == null) // replace the entire collection
                        {
                            base.Clear();
                            foreach (var item in results)
                            {
                                base.Add(item);
                            }
                        }
                        else
                        {
                            Merge.Invoke(this, results);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (RefreshFailed != null)
                {
                    await RefreshFailed.Invoke(this, ex);
                }
            }
            finally
            {
                IsRefreshing = false;
                AfterRefresh?.Invoke(this, refreshParameter);
            }
        }