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

The Archive Base Latest Questions

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

I need an advice on multithreading implementation in WinForms C# application. We have an

  • 0

I need an advice on multithreading implementation in WinForms C# application. We have an image – with text and numbers and there are separate methods to OCR different types of data. For example:

decimal[] numbers = getNumbers(bitmap, dictionary1);
string[] text = getText(bitmap, dictionary2);
int[] integers = getInts(bitmap, dictionary3);
// add 5 more data types (list, int[], etc..)

As the result, whole proccess takes approximately 1 second.

I was thinking about running OCR on different threads, simultaneously. For that reason I tried to use Task Factory:

decimal[] numbers;
Task.Factory.StartNew(() =>
{numbers = getNumbers(bitmap, dictionary1);});
string[] text;
Task.Factory.StartNew(() =>
{text = getText(bitmap, dictionary2);});
textBox1.Text = "" + text[0]; // nothing

but I was not getting any results..

so is it possible to implemet multithreading in my case? Which approach do I have to use?

  • task factory
  • background worker
  • threads
  • or something else?

If possible, can you give me a little advice on how to use your method, because TaskFactory failed when I tried to use it (as in example).

Edit:

seems like

textBox1.Text = "" + text[0];

was executed faster than

string[] text;
Task.Factory.StartNew(() =>
{text = getText(bitmap, dictionary2);});

that’s why TextBox field was empty.. so I moved “textBox1.Text = “” + text[0];” at the very end of the code, and finally got the result..

Edit 2:

ok, tasks do not make any difference.. I’m getting the same speed test result without them.

  • 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-31T22:49:25+00:00Added an answer on May 31, 2026 at 10:49 pm

    You’re starting tasks correctly, but you’re never waiting for them to finish. What you want to do is something similar to;

    Task[] tasks = new Task[2];
    decimal[] numbers;
    tasks[0] = Task.Factory.StartNew(() =>
       {numbers = getNumbers(bitmap, dictionary1);});
    string[] text;
    tasks[1] = Task.Factory.StartNew(() =>
       {text = getText(bitmap, dictionary2);});
    
    Task.WaitAll(tasks);  // Wait for all parallel tasks to finish 
                          // before using their output.
    
    textBox1.Text = "" + text[0];
    

    More example code can be found here.

    Alternately, you can return the value from the task instead of assigning it to a variable and use Task.Result which when you access it will wait for the task to finish and return the result of the Task.

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

Sidebar

Related Questions

I need advice on how to have my C# console application display text to
I need advice. I have application that imports 10,000 rows containing name & address
I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with
I really need advice on how to do the following. I have tried several
I think I have this working but I need advice. I'd like to know
I have 3 tables, I need advice on how to get data from them.
I need advice on what to do. I have several applications on App store
I need advice. My server application send objects with not inialized proxies. Primitive types
I need advice on this snippet $text = preg_replace('|(A.*)?A(.*)C|', '$1foo$2bar', $text); This will match
I need advice regarding text analysis. The program is written in php. My code

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.