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

  • Home
  • SEARCH
  • 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 6165241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:07:55+00:00 2026-05-23T22:07:55+00:00

I’m trying to update a Ultragridrow cell in a background worker, but this is

  • 0

I’m trying to update a Ultragridrow cell in a background worker, but this is throwing a InvalidOperation Exception when this is called more than 1 time.

Here you have the method that starts the RunWorkerAsync.

    private void RefreshGridCacheStart()
    {
        try
        {
            if (this.uGridCache.Rows.Count == 0)
            {
                return;
            }

            if(!workerThread.IsBusy)
            {
                workerThread.DoWork += LookUpHostnames;
                workerThread.ProgressChanged += UpdateCacheHostCell;
                workerThread.RunWorkerCompleted += WorkerCompleted;
                workerThread.WorkerReportsProgress = true;
                workerThread.RunWorkerAsync();
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message + "\n" + ex.Source + "\n" + ex.ToString());
        }
    }

This is the DoWork method:

    private void LookUpHostnames(object sender, DoWorkEventArgs e)
    {
        var rowValues = new object[2];

        try
        {
            foreach (UltraGridRow row in uGridCache.Rows)//here is were I get an invalid operation exception
            {
                string cellValue = row.Cells["Host"].Text;
                if (Globals.cNet.isValidIP(cellValue))
                {
                    rowValues[0] = row;
                    rowValues[1] = cellValue;

                    workerThread.ReportProgress(0, rowValues);

                    string resolvedHostname = Globals.cIPLookup.LookupHostFromIP(cellValue);
                    rowValues[1] = resolvedHostname;

                    workerThread.ReportProgress(0, rowValues);
                }
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message + "\n" + ex.Source + "\n" + ex.ToString());
        }

    }

And this is the Report Progress method:

    private void UpdateCacheHostCell(object sender, ProgressChangedEventArgs e)
    {
        var rowValues = e.UserState as object[];
        var row = (UltraGridRow) rowValues[0];
        var sMesage = (string) rowValues[1];

        row.Cells["Host"].Value = sMesage;
    }
  • 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-23T22:07:56+00:00Added an answer on May 23, 2026 at 10:07 pm

    You can find your answer here Different question but ultimately the same problem. Your are changing data inside a foreach loop which invalidates the enumerator.
    There are 2 possible solutions I see from reading your code

    • Save all changes that need to be made to an List of changes and only report progress once after the foreach loop. This might not be a very good solution though since you are processing in the background. If there is other code running that could also change the data in the grid you would get the same error again.
    • Since you are not adding rows you could easily change the foreach to a for loop. This might also lead to an issue if code on the main thread could add, or worse, remove rows
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.