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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:59:49+00:00 2026-05-31T09:59:49+00:00

I have a class that I created and in the class I do some

  • 0

I have a class that I created and in the class I do some multi-threading. Usually to do my multi-threading on a form I would use the following method…

//Thread Safe Functions
delegate void Thread_Safe_SendMessage_Progress_Callback(string sProgress);
private void Thread_Safe_SendMessage_Progress(string sProgress)
{
    if (this.InvokeRequired)
    {
        Thread_Safe_SendMessage_Progress_Callback d =
            new Thread_Safe_SendMessage_Progress_Callback(Thread_Safe_SendMessage_Progress);
        try
        {
            this.Invoke(d, new object[] { sProgress });
        }
        catch
        {
            //ObjectDisposedException
        }
    }
    else
    {
        //Fire up the thread event
        SendMessageThread_Progress(sProgress);
    }
}

Now that works perfect! At this point I try to bring the multi-threading into a class i made. When I do that everything seems to be great with the exception of the InvokeRequired property and the Invoke method do not exist within my class. So using this.InvokeRequired throws an error… To give my class that property I do this… (Note that m_iThreadID is set in the constructor and when the thread is created to start with)

private bool InvokeRequired
{
    get
    {
        //Get the current thread id
        int iThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;

        //Compare and return results
        return (iThreadID != m_iThreadID);
    }
}

Now the only thing left is the Invoke method… How do I get that to work?

  • 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-31T09:59:50+00:00Added an answer on May 31, 2026 at 9:59 am

    Invoke method isn’t so “easy” to replicate (side question: why don’t you use BeginInvoke? I guess you may don’t need to raise the event synchronously). You can get the first form in Application.OpenForms (copy before use!) and inspect that to check for InvokeRequired and BeginInvoke/Invoke.

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

Sidebar

Related Questions

I am creating some multi-threaded code, and I have created a JobDispatcher class that
I have a custom thread pool class, that creates some threads that each wait
Currently I have created a ABCFactory class that has a single method creating ABC
I have an ExpenseType object that I have created with the following migration: class
I have created a non-form c# program that uses the NotifyIcon class. The text
I have a binary tree class that is created with a root node and
I have created a button CSS class that uses background images with different positions
I have a control that is created like so: public partial class MYControl :
I have a collection of classes that inherit from an abstract class I created.
I have some models and I want to generate a multi-selection form from this

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.