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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:46:26+00:00 2026-06-13T08:46:26+00:00

I managed to get a webcam running using Aforge. The code can be found

  • 0

I managed to get a webcam running using Aforge. The code can be found in my answer here.

Now I want to do some computer vision stuff and return back some results to the main form. The threading problem I have is in this part from that code:

void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{ Bitmap video = (Bitmap)eventArgs.Frame.Clone();
  pictureBox1.Image = video;
  // count red colors  
  // not yet written
  TextBox1.text = "demo error";  // >> i like to return a value to the main form
 }

The problem however is it’s doing the video frames in another thread, and now I can’t return answers from that thread to the main form back. I didn’t write the Aforge, I only linked it and made it work on my form.

I can’t change the way how Aforge video works. I mean it was never made to result something back that’s something I like to do. Are there ways to get a result back, like a string text in a textbox. On the main form where this code runs from?

I am able to follow a sample code of threading but this is a bit over my head since I got not much influence on how video acquisition in Aforge was designed.

I have been wondering if raising another thread just to update a textbox might work but I am not that sure and wonder that in the end one would create to many threads, causing to much kernel switching load.

Some additional info: the code thread above is started with this button function below.

private void button1_Click(object sender, EventArgs e)
{ FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
  FinalVideo.NewFrame += new  NewFrameEventHandler(FinalVideo_NewFrame);
  FinalVideo.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-06-13T08:46:27+00:00Added an answer on June 13, 2026 at 8:46 am

    Try writing your code like this:

    void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        Bitmap video = (Bitmap)eventArgs.Frame.Clone();
        pictureBox1.Invoke((Action)(() =>
        {
            pictureBox1.Image = video;
            TextBox1.text = "demo error";
        }));
    }
    

    The .Invoke pushes the execution of the Action delegate onto the same thread that created the pictureBox1 control, in order words, the UI thread.

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

Sidebar

Related Questions

I managed to get FIT up and running using fixtures implemented in C#. I
So I've managed to get Code First running and it works great. Since I
I managed to get some help from a previous question and I have the
I managed to get custom themes running for Tabs but still got a lil
I managed to get this code to compile with out error. But somehow it
I've managed to get Teamcity running and connecting into bitbucket and the final step
I managed to get Ajax working in Rails, specifically using remote_form_for tag to add
I managed to get a set of images loaded using Python. I'd like my
I managed to get Ubuntu running on a mobile device. I need to automate
I have managed to get mongrel_cluster running on my Windows server (v 1.0.5) ok,

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.