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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:28:59+00:00 2026-05-22T21:28:59+00:00

I have a class that handles some realtime action in a thread that it

  • 0

I have a class that handles some realtime action in a thread that it starts. There are other theads in play in this application as it is very complex. When This rt action starts i need to pop up a window and close it when it is done. Sounds easy.

There are events that I hook to when this action starts and stops. In those event handlers I place the code:

        private void Voice_SpeakStarted(object sender, TMSpeakStartedEventArgs e)
    {

        InfoWindow = new Form();
        InfoWindow.Show();
    }

    /// <summary>
    /// this is the event handler speaking stops
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Voice_SpeakCompleted(object sender, TMSpeakCompletedEventArgs e)
    {
        if (InfoWindow.InvokeRequired)
        {
            InfoWindow.Invoke(new Action(() =>
            {
                InfoWindow.Close();
            }));

            InfoWindow.Hide();
        }
    }

There are times I get an error that the thread has terminated. (An error occurred invoking the method. The destination thread no longer exists.)

I always seem to get the window to show. I can not seem to get the window to close.

I also see that sometime the handler themselves do not get called.

I need help bad. I can post more code if it would be helpful.

Edited – added more code
This is how I start the class

        public void start()
    {
        //It's already alive, nothing to do
        if (alive) return;

        //Make sure this is the only place where alive is set to true
        alive = true;

        Voice.SpeakCompleted += new Speech.TMSpeakCompletedDelegate(Voice_SpeakCompleted);
        Voice.SpeakStarted += new Speech.TMSpeakStartedDelegate(Voice_SpeakStarted);


        dispatch = new Thread(new ThreadStart(ProcessSayList));
        dispatch.Start();
    }

The constructor of the class is

    public AnimationControl(dynamic parent)
    {
        Parent = parent;
        Voice = new Speech();

        q = Queue.Synchronized(new Queue(1000));
        start();
    }
  • 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-22T21:29:00+00:00Added an answer on May 22, 2026 at 9:29 pm

    You should really specialize your thread and stop calling code managed by other thread form any thread. Use message queues to communicate actions to your thread. This is the safest way to do multi-threading.

    Example in pseudo-code:

    Thread1
    {
      while (1)
      {
        read my last message in my queue;
        do something according to this message like:
        openwindow();
        or closewindow();
      }
    }
    
    Thread2
    {
      My life is short, I just need to post a message to thread1
    }
    
    
    Thread3
    {
      etc.
    }
    

    There are ready-to-use structures for such a thing on every system. And by doing so, it will be much more easy to understand what’s happening in case of problem like that. Of course, if you don’t take care, your threaded program can become absolutely linear; the goal is to make sure some parts of actions can be made in parallel and do not create a chain of threads waiting each other, one by one 🙂

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

Sidebar

Related Questions

There is application that handles text commands. I have a Qt widget that is
I have a class that implements properties in a specific way, to handle some
I have some event handler on a boundary class that manages a persistence mechanism
I have a class that handles events from a WinForms control. Based on what
We currently have a utilities class that handles a lot of string formatting, date
I have a main class in a program that launches another class that handles
I have a class that inherits from ObservableCollection(Of MyObject) and the MyObject class handles
I have a C++ RAII class for managing Win32 HANDLEs using boost::shared_ptr<> that looks
I have written a class that will handle internal logging in my application. Now
I have a Delegate class that handles responses from CLLocationManager and prints them via

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.