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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:14:48+00:00 2026-05-22T20:14:48+00:00

I am creating a quick’n’dirty utility that will enable editing of data read sequentially

  • 0

I am creating a quick’n’dirty utility that will enable editing of data read sequentially from a set of files. Here’s a very simplified explanation of what will happen in a single iteration of a loop:

  • Read a line from the input stream
  • Parse it and use the parsed results to populate form controls
  • Allow user editing and await a confirmation button click
  • Retrieve the updated form control values and write to the output stream

What I can’t figure out is how to integrate the processing loop with the event-driven UI. For example, how do I suspend operation of the loop while waiting for user input.

I understand that this is possible by launching the loop operation on its own thread and writing code to manage its interaction with the UI thread, but I am wondering if there is a simpler approach that works out of the box.

Thanks for any ideas you may be able to offer.
Tim

  • 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-22T20:14:49+00:00Added an answer on May 22, 2026 at 8:14 pm

    I can think of 2 approaches to do that:

    • The easiest is probably to use a modal dialog: when your worker thread needs input from the user, display a dialog, which is a blocking operation. Something like that:

      // Worker thread loop
      while(...)
      {
          ...
      
          // prompt user for data (invoke synchronously on UI thread)
          UserData data = (UserData)window.Invoke(PromptUserData);
      
          ...
      }
      
      ...
      
      
      
      UserData PromptUserData()
      {
          UserInputDialog dlg = new UserInputDialog();
          dlg.ShowDialog();
          return dlg.UserData;
      }
      
    • The other option, if you don’t want to use a modal dialog, is to use a wait handle to synchronize the worker thread and the UI:

      private readonly AutoResetWaitHandle _userInputWaitHandle = new AutoResetWaitHandle(false);

      ...
      
      // Worker thread loop
      while(...)
      {
          ...
      
          // Setup the UI to allow user input
          window.Invoke(SetupUIForInput);
          // Wait for the input to be validated
          _userInputWaitHandle.WaitOne();
          ...
      }
      
      
      ...
      
      void SetupUIForInput()
      {
          // Enable the UI
          inputForm.Enabled = true;
      
          // Whatever else you need to do...
          ...
      }
      
      
      void buttonOK_Click(object sender, EventArgs e)
      {
          // Signal the worker thread to continue
          _userInputWaitHandle.Set();
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a quick backup script that will dump some databases into a
I am creating a quick and dirty prototype (C#) of an object-relational mapping tool.
I am creating a little voting mechanism that sends a quick database timestamp through
I want to create a quick function that will console.log a variable name and
First is it dumb to use DJango as a quick/dirty data access method? We
While creating classes in Java I often find myself creating instance-level collections that I
I've been supplied a web service by a colleague that I tested by creating
I've got a strange situation where deleting and creating directories in quick succession on
I ran into a little problem today when I was creating a really quick
When creating a quick campaign in Dynamics CRM 4.0 the onload javascripts for appointment,

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.