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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:28:32+00:00 2026-05-14T07:28:32+00:00

I have some code which is been running by a backgroundworker I’d like some

  • 0

I have some code which is been running by a backgroundworker I’d like some specific code which shows some GUI to run in the main thread context (2 reasons 1. it should be blocking 2.I know it’s problematic to handle gui controls from a background worker)
I raise an event pass the class and listen to the event in the mainForm from there I check if invoke required and reinvoke. then call the public method of the instance I want to run in the main thread. I have a few questions:

  1. is there any problem to handle data member which are created in the backgoundworker context from the main thread – for both reading and chaning valuse

  2. is there any design pattern for such issue? Idealy I’d like to run any delegate- any return value and a few genric parameters- as func built in delegate- that is problematic because It means if I want to support up to 3 parameters with or without return values I’ll have to have 6 events and 6 listeners which actually do the same – does anyone have an idea of how to do this correct?
    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-05-14T07:28:33+00:00Added an answer on May 14, 2026 at 7:28 am

    I just wrote this for a similar question.

    I use threads for these kind of stuff.

    somewhere in my code:

    // Definition 
    private static Thread TH; 
    

    ….

    // When process starts
    TH = new Thread(new ThreadStart(Splash_MyCallBack)); 
    TH.Start();
    

    ….

    // This method starts the form that shows progress and other data
    static private void Splash_MyCallBack()
    {
       frmLoading FL;
    
       FL = new frmLoading();
    
       FL.ShowDialog();
    
    } /* Splash_MyCallBack*/
    
    // Your process calls Splash_Stop when it is done.
    static public void Splash_Stop()
    {
       TH.Abort();
    } /* Splash_Stop*/
    

    frmLoading performs the visual stuff, while in the background I have a very processor-intensive task.
    My process reports to an interface its progress. frmLoading implements that interface so it is aware of it and can show whaever it is needed (2 progress bars in my case)
    Tha only catch is, frmLoading must have this in the constructor:

    Control.CheckForIllegalCrossThreadCalls= false;
    

    which may be risky in some scenarios (not my case).

    I think that the fact that the main process calls an interface to update progress, and the real interface consumes that is a pattern.
    Hope this helps, I can add more stuff if you like.

    Regards,

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

Sidebar

Ask A Question

Stats

  • Questions 438k
  • Answers 438k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My impression is that namespaces are used in a cargo… May 15, 2026 at 4:28 pm
  • Editorial Team
    Editorial Team added an answer If you're happy with the overall performance, just the loading… May 15, 2026 at 4:28 pm
  • Editorial Team
    Editorial Team added an answer The problem is caused by one of these lines: cmdItemSearch.Parameters["@EndDate"].Value… May 15, 2026 at 4:28 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.