Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7127831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:04:26+00:00 2026-05-28T11:04:26+00:00

I have a window with a telerik gridview in it and i update this

  • 0

I have a window with a telerik gridview in it and i update this gridview every 1 minute. i have a refresh method and every 1 minute i call it.

i cant use BackgroundWorker because my CollectionViewSource is in the UI thread and backgroundworker cant use it. my question is how can i call this refresh method from another thread?

somewhere i see this sample code:

Application.Current.Dispatcher.BeginInvoke(new Action(() => this.Refresh()));

is this a true way that i use the above code in Refresh_Executed?
please help me.

this is my Refresh method:

public ObservableCollection<RequestView> AllRequestsData { get; set; }

private void Refresh()
    {
        using (ArchiveEntities db = new ArchiveEntities())
        {
            var data = db.RequestSyncs.Where(x => x.UserId == null);
            if (data.Any())
            {
                string IdList = String.Join(",", data.Where(x => x.IsNew).Select(x => x.RequestId));
                if (!String.IsNullOrWhiteSpace(IdList))
                {
                    foreach (var item in db.RequestViews.Where("it.id in {" + IdList + "}"))
                    {
                        this.AllRequestsData.Add(item);
                    }
                }

                foreach (var item in data.Where(x => x.IsDeleted))
                {
                    RequestView rv = this.AllRequestsData.Where(x => x.Id == item.RequestId).SingleOrDefault();
                    if (rv != null)
                    {
                        this.AllRequestsData.Remove(rv);
                    }
                }

                foreach (var item in data)
                {
                    db.RequestSyncs.DeleteObject(item);
                }

                db.SaveChanges();
            }
        }
    }

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:04:26+00:00Added an answer on May 28, 2026 at 11:04 am

    May be in common it’s true way, but it depends on content of the Refresh method, could you provide the content of it?

    EDIT
    Usually I load data in view model using async theads and don’t really need to update RadGridView. But when, for instance, I need to collapse all groups e.t.c I use radGridView.Dispatcher.BeginInvoke(…).

    UPDATE

    There is no need to update RadGridView. You are updating it’s ItemsSource property. I would not reccomend to use Dispatcher in such situation and I would use Task Parallel Library to recieve plain data from database and update ItemsSource with the synchronization with the current UI thread:

    Task.Factory.StartNew<IEnumerable<RequestSyncPlain>>(() =>
    {
      return result;
    }).ContinueWith(_ =>
    {
      try
      {
        _.Wait();
      }
      catch (AggregateException ae)
      {
      }
    
      foreach (var requestSyncPlain in _.Result)
      {
        var requestSync = new RequestSyncViewModel(requestSyncPlain);
    
        requestSyncObservableCollection.Add(requestSync);
      }
    }, TaskScheduler.FromCurrentSynchronizationContext());
    

    Note, that you should upgrade this method to implement your needs (you could put you database methods in first task and may be return Tuple from two colelctions) and this is just idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have to display customize popup window in telerik grid because i cannot display
I have a window in WPF which shows some media contents. This content contains
I am using ASP.NET MVC architecture.I have a telerik window on a button click,
I have a web application developed in ASP.net & C#. I also use Telerik
I have a telerik window with multiple divs inside it whose visibility is set
I have asp.net form that contains fields. When I access this window, my javascript
I have a Control that looks like this: <telerik:RadCodeBlock runat=server> <script type=text/javascript> function refresh()
I'm using MVC2 and have a telerik popup window in which I'm doing a
I have window form in my WPF Application when I open new window from
I have a Window where I have put a Frame. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.