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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:16:11+00:00 2026-06-11T21:16:11+00:00

I want to show a text in a label for a particular time so

  • 0

I want to show a text in a label for a particular time so I did a search on google and I found these two solutions :

The first solution is :

public void InfoLabel(string value)
{
    if (InvokeRequired)
    {
        this.Invoke(new Action<string>(InfoLabel), new object[] { value });
        return;
    }
    barStaticItem3.Caption = value;

    if (!String.IsNullOrEmpty(value))
    {
        System.Timers.Timer timer = 
                                new System.Timers.Timer(3000) { Enabled = true };
        timer.Elapsed += (sender, args) =>
        {
            this.InfoLabel(string.Empty);
            timer.Dispose();
        };
    }
}

The second solution :

private void ShowTextForParticularTime(String caption)
{
    Timer t = new Timer { Interval = 5000, Enabled = true};
    t.Tick += (sender, args) => OnTimerEvent(sender, args, caption);  
}

private void OnTimerEvent(object sender, EventArgs e, String caption)
{
    barStaticItem3.Caption = caption;
}

Could you please tell me the deffrence between the two solutions, and why we use this symbole “=>” , also I understood nothing from this line :

if (InvokeRequired)
{
    this.Invoke(new Action<string>(InfoLabel), new object[] { value });
    return;
}
  • 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-11T21:16:13+00:00Added an answer on June 11, 2026 at 9:16 pm

    Okay, there is a good amount to explain here.

    There is no major differences between the two options you have shown. The reason they look different is because the first id declaring a delegate method (lambda expression) inside the public method, while the second is just creating an event handler. They do almost the exact same thing. Infact you can see that in the delegate method you have the tradition event handler prameters (object sender, EventArgs e). Personally I prefer the second solution because it looks cleaner to me.

    Invoke Required is used to handle threading. In C# errors will be thrown if a thread that didn’t create a visual object tries to alter the visual object. To get around this we make a call to the thread that created the visual object by calling “Invoke”. The “InvokeRequired” property just tells us if the current thread did not create the visual object. You should always use this when you are threading or making delegate methods (because you can’t control the thread that runs them.)

    I hope this brief explanation helps. Comment if it is unclear

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

Sidebar

Related Questions

I want to show a text in a label for a particular time in
I have a label that I want to use to show some text. I
I have a label that i want to show it's Text(1234567) Like A Number
I have a statusbar label and I want to show a text on my
I want to show N/A text in grid view label if value is not
I just want to show text please wait while app is searching for satellite
I am using infragistic's ultragrid and I want to show the text portion of
I am using Delphi, and I want to show custom text in the buttons
I'm using jquery validate to validate my forms. I want to show a text
I want to show some help text(much like in a webpage when a field

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.