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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:42:33+00:00 2026-06-11T23:42:33+00:00

In my application I have class that is responsible for all database actions. It

  • 0

In my application I have class that is responsible for all database actions. It is called from main class and uses delegates to call methods after action is complete.
Because it is asynchronous I must use invoke on my GUI, so I’ve created a simple extensions method:

 public static void InvokeIfRequired<T>(this T c, Action<T> action)
            where T: Control
        {
            if (c.InvokeRequired)
            {
                c.Invoke(new Action(() => action(c)));
            }
            else
            {
                action(c);
            }
        }

This works fine when I try to call it on textBox:

textBox1.InvokeIfRequired(c => { c.Text = "it works!"; });

but when I try to call it on ToolStripStatusLabel or ToolStripProgressBar I get an error:

The type ‘System.Windows.Forms.ToolStripStatusLabel’ cannot be used as
type parameter ‘T’ in the generic type or method
‘SimpleApp.Helpers.InvokeIfRequired(T, System.Action)’. There is
no implicit reference conversion from
‘System.Windows.Forms.ToolStripStatusLabel’ to
‘System.Windows.Forms.Control’.

I know that this is probably a simple fix, but I just can handle it :/

  • 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-11T23:42:34+00:00Added an answer on June 11, 2026 at 11:42 pm

    This is because ToolStripItem (base for those two causing an error) is a Component and not a Control.
    Try calling your extension method on the tool strip that owns them and adjust your delegate
    methods.

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

Sidebar

Related Questions

Problem in words: For my application, I have a class that reads from a
I have a logger class that is used all across my application, both in
I have one grails application.In that I have one model class named Book. From
In a C# Winforms (3.5) application I have added a class that contains many
I have a class that extends Application. The class is fairly extensive. When the
I have written a class that will handle internal logging in my application. Now
In a client application I have a DBIx::Class model 'Todo' that can be linked
I'm working on an application. I have a servlet (writeDataBase.class) that writes some information
I'm working on an iPhone application. I have an object of class Row that
I have an application that opens another class using intent : private void createRepository(){

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.