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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:02:00+00:00 2026-05-20T22:02:00+00:00

I have an application which posts progress/status messages as it runs (it’s a database

  • 0

I have an application which posts progress/status messages as it runs (it’s a database schema updater). Because it can run with or without a UI, those messages have to go to either the Console or a simple WPF window. The WPF window is opened modally. All it contains is a listbox to which the messages get posted.

In order to deal with threading issues (the GUI has to be on an STA thread, while the Console isn’t) I use the following logic:

if( args.NoUI )
{
    // we're just doing plain old console-based logging
    frame = new nHydrateInstallationFrame(installer) { ReportingThreshold = threshold };

    frame.Execute();
}
else
{
    // GUI has to be on an STA thread, so wrap ourselves and go!
    frame = new nHydrateUIInstallationFrame(installer) { ReportingThreshold = threshold };
    // the Execute method on an nHydrateUIInstallationFrame object calls ShowDialog().
    // when the resulting window opens, the actual installation process begins to execute.
    // this allows UI-based logging, and, more importantly, keeps the logging window open
    // until the user explicitly closes it after the installation process completes. If 
    // we don't do this kind of indirect execution, the logging window will immediately close
    // after the installation method ends, which will keep the user from reviewing the
    // logging output
    Thread staThread = new Thread(frame.Execute);
    staThread.SetApartmentState(ApartmentState.STA);
    staThread.Start();
    staThread.Join();
}

This is just an extract, but it shows the approach, I think (i.e., creating a separate thread for the UI, setting its apartmentstate, starting it and joining it). This causes the Execute method on the frame (the object containing the output “sink”) to run. The Execute method calls the actual database schema modification routine, passing itself as a parameter. The schema modification routine writes messages to the frame, which then outputs them to either the console or the UI.

This all works fine…except that the messages posted to the UI window don’t show up until after the process being run by the UI completes. Except, I should add, if you expand the UI message window using the mouse. In that case, the messages show up as they are posted.

This makes me think I’ve got some kind of focus problem, with the UI window not having focus unless I play around with it. But I’m not sure. I did try setting focus to the UI window as soon as it was created, but that didn’t do anything.

I’d appreciate thoughts on how I can get the messages posted to the UI window to show in real time.

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

    My suspicion is that you run the database upgrader on the UI thread. In that case run the upgrade routine on a background thread and post yor messages to the window from there. You might want to have a look at the BackgroundWorker class for that purpose.

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

Sidebar

Related Questions

I have an application which get copied and run on client machines. The program
I have an application which really should be installed, but does work fine when
I have an application which extracts data from an XML file using XPath. If
We have an application which needs to use Direct3D. Specifically, it needs at least
I have an application which behaves as a slideshow for all pictures in a
I have an application which is a portal application and I want to allow
I have an application which takes a string value of the form %programfiles%\directory\tool.exe from
I have an application which has to live as a service, I create an
I have one application which uses the standard .NET forms authentication cookie, now I
I have an application which tries to load some expected registry settings within its

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.