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 7864021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:39:54+00:00 2026-06-02T23:39:54+00:00

alredy a question out about this. but here comes another question little diffrent, and

  • 0

alredy a question out about this. but here comes another question little diffrent, and i cant find any awnsers to it!

String text = this.GuiThread(() => this.comboBox1.Text); 

 if (text == "this")
 {
   //do somthing spectacular!
 }

text is an empty variable or so..

Use of unassigned local variable. this is the ERROR i get..and iv tested all examples i can find here and at msdn.

im also having :

  public static class ControlExtensions
    {
        public static void GuiThread(this Control ctrl, Action action)
        {
            if (ctrl.InvokeRequired)
            {
                ctrl.BeginInvoke(action);
            }
            else
            {
                action.Invoke();
            }
        }
    }

ideas?

  • 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-06-02T23:39:56+00:00Added an answer on June 2, 2026 at 11:39 pm

    This code cannot compile. The GuiThread returns void, you are trying to assign that to a string. How you can get an exception is unguessable. It needs to at least look like this:

    public static class ControlExtensions {
        public static T GuiThread<T>(this Control ctrl, Func<T> action) {
            if (ctrl.InvokeRequired) {
                return (T)ctrl.Invoke(action);
            }
            else {
                return action();
            }
        }
    }
    

    Don’t write code like this, the actual ComboBox text you’ll read is pretty random since it can be obtain while the user is modifying it. Give a thread the arguments it needs when you start it. The BackgroundWorker class keeps you out of trouble.

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

Sidebar

Related Questions

(This question is not about programming, but about how to avoid doing any programming.
There's already a question on this here. But i want to know if its
Apologies if I missed this question already, but I searched and couldn't find it.
I have already posted a question about this, but the situation has changed sufficiently
I have figured out a lot about nhibernate, but this seems to be my
I just asked a question about this but I want to go at it
Introduction: I asked this question on the P2-forum already but I couldnt get any
This question already has an answer here: What are Extension Methods? 5 answers Usage
I've asked this question already this week but am rephrasing it with the hope
This question is already answered. I discovered what the problem is. But, I'm posting

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.