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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:53:33+00:00 2026-05-31T06:53:33+00:00

I am new to C#, i have read something about threading like begininvoke and

  • 0

I am new to C#, i have read something about threading like begininvoke and eventhandler stuff. but could you explain what’s the following code is doing on the richtextbox?

private void Log(LogMsgType msgtype, string msg)
{
  rtfTerminal.Invoke(new EventHandler(delegate
  {
    rtfTerminal.SelectedText = string.Empty;
    rtfTerminal.SelectionFont = new Font(rtfTerminal.SelectionFont, FontStyle.Bold);
    rtfTerminal.SelectionColor = LogMsgTypeColor[(int)msgtype];
    rtfTerminal.AppendText(msg);
    rtfTerminal.ScrollToCaret();
  }));
}

*is this Invoke similiar to begininvoke?
* in the msdn, it describe it as Executes the specified delegate on the thread that owns the control’s underlying window handle.Not quite sure about the meaning of 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-05-31T06:53:35+00:00Added an answer on May 31, 2026 at 6:53 am

    could you explain what’s the following code is doing on the richtextbox?

    It executes the code in the anonymous method on the UI thread.

    is this Invoke similiar to begininvoke?

    Yes, but Invoke is synchronous, whereas BeginInvoke is asynchronous. In other words, a call to Invoke will block until the UI thread executes the specified action, whereas BeginInvoke will return immediately, without waiting for the action to be executed by the UI thread.

    in the msdn, it describe it as Executes the specified delegate on the thread that owns the control’s underlying window handle.Not quite sure about the meaning of it.

    In Windows Forms, controls can only be accessed on the thread that created them. So if you’re executing something on a different thread, and you perform an action on a control from this thread, you can’t do it directly; you need to ask the UI thread to perform this action. That’s what Invoke and BeginInvoke are for.

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

Sidebar

Related Questions

I am new to WPF, have read some books about it, but now I
I'm fairly new to working with relational databases, but have read a few books
I just started to read about this new technology... Does someone have some knowledge
I have the following basic code to read a text file from a StreamReader:
i am new to this backgroundworker thing i have read some articles about how
i have read a lot about what im asking, but the closest thing i
I am new to ASP.net MVC architecture. I have read in some articles that
I have used the module Mail::Webmail::Gmail to read the new messages in my Gmail
I have some problem with my open new window popup which it can read
I have trouble with adding new row to my UITableView. I read similar questions

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.