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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:34:06+00:00 2026-06-08T07:34:06+00:00

I want to do a simple thing. I have a secondary thread listening to

  • 0

I want to do a simple thing.

I have a secondary thread listening to a usb reader, when the reader “reads” something, the thread fires an event. And that event starts a timer, but the timer does not work, I’m sure it is because about the threads.

Also, the timer must change some images in the form so this must be done in the main thread.

I hope I’m clear.

private void listenReader()
    {
        while (whileState)
        {

                if (readsSomething)
                {
                    evt.OnSomeEvent();
                    break;
                }

        }
    }

    private void eventStartsThisMethot(){
        //do a lot of things and start the timer
        }

    private void counter(){
        pictureBox.Image = Resources._5;
    //the timer ticks this methot
    }

So, listen reader need to be on separate thread for obvious reasons, but the second method must be done from the main thread, so I use an event, but if you have another idea.

Thanks

  • 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-08T07:34:07+00:00Added an answer on June 8, 2026 at 7:34 am

    Since you added the [picturebox] tag, we can assume this is Windows Forms (Winforms). The event handler for your reader thread will execute on the reader thread and you need to execute code (in response to the event) on the UI thread.

    You can use your Form’s BeginInvoke method to execute arbitrary code on the UI thread

    private void ProcessMessageOnUIThread(YourMessageType msg)
    {
        // Process here
    }
    
    private void ReaderThreadEventHandler(YourMessageType msg)
    {
        // Invoke the UI thread to process the message
        BeginInvoke(new Action(ProcessMessageOnUIThread), msg);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's really simple, I just want one screen. Wow, that [shiny thing] must have
I'm stunned by a simple thing that I want to accomplish but does not
I want to know a simple thing, which i couldn't get it is that
I have a simple thing to do : I want to encryt data using
Below is the code that I have written. I want to do the simple
There's this simple thing i want to do. I have to add a current
I want to do this simple thing: create a uinavigationcontroller but that doesnt show
I have input with password type. And I want to do simple thing. If
I want to do very simple thing, but I'm not success. I have button
there's a simple thing in papervision I can't do , I want to have

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.