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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:50:58+00:00 2026-06-16T09:50:58+00:00

I have made my first attempt at using dependency injection to loosely couple a

  • 0

I have made my first attempt at using dependency injection to loosely couple a new application. My problem is how to pass status information back to the user. In the old days with all the code crammed into the GUI it was pretty easy if very messy and unmaintainable. The arrangement of classes is something like this (please do not check my UML skills – they are non existent):

Application Overview

If we take the right hand side. The AirportsInformationRepository just stores data and makes it available to the Controller when asked. At the start it gets the information using the Persist class to get files matching a given filter from the users hard drive. It uses the decompiler to extract information from a file. All this works fine and the information itself gets to the GUI as it should.

My problem is, in parallel, how to tell the user what is happening. This can occur in the decompiler, for example, if the file it gets cannot be decompiled or perhaps contains no data. It can occur in the Persist class if the config file is telling lies and some folder does not exist. Such issues should not stop the process unless there is a fatal error.

If there is a fatal error then it needs to get back to the user at once and the overall process should stop. Otherwise warnings can be collected through the process somehow and then displayed when the scan is completed.

I am familiar with logging and the application does have a logger that is monitoring the application for unhandled exceptions and other failures. This writes to disk and I use this like most would to deal with bugs. I don’t want to use this for status reporting to the user since to be honest nothing is wrong with the app if a file is not found or the user entered an invalid path to the config file.

I have considered:

  • accumulating a log in each class and passing it back to the consumer when the process completes (or fails). I am finding that really messy
  • using events but if the consumer is subscribing and the events are passing up the chain in the same way as the log then I don’t see that is much better. I guess an alternative is to have the GUI subscribe directly but it should not know anything about the decompiler….
  • A home rolled logger that is either a static class or is instantiated in program.cs
  • Some sort of messaging framework – which I admit I am not clear about but I think is rather similar to a central event handler whereby the GUI could subscribe to it without having to know anything about the other classes.

So to summarise. What is the best way to accumulate ‘business as usual’ status information and give it to the GUI at the end of a scan, at the same time being able to stop on a fatal issue.

Thanks in advance for reading this. Apologies for the length of the post.

EDIT
I should have said that the app is using NET 3.5. I would change this to get an elegant solution but….

  • 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-16T09:50:59+00:00Added an answer on June 16, 2026 at 9:50 am

    When you deal with a typical “flow” of processing, possibly even multithreaded/concurrent processing flow the best approach to take is “mailslots”/message pumps. By exchaging messages you can easily coordinate multiple layers of your application and that includes reporting errors, notifying the next chain of command etc.. I do not mean Windows messages, I mean something like:

    public abstract class Message
    {
       public abstract void Process();
    } 
    

    Then:

    public class MessageQueue
    {
       private Queue m_Queue;
       public void Post(Message msg) {....}
       public void Process() {.....}
    }
    

    Then you allocate a MessageQueue on every thread/processing tier of your app and pass messages like so:

        GUIMessageQueue.Post(
               new ErrorMessage("Internal async file reader ran out of buffer"));  
    

    On GUI thread put a timer that read GUI queue and calls it’s Process().
    Now you can create many Message-derived work items to execute various tasks that very easily orchestrate between threads/logical tiers. Also, messages may contain references for datapieces that they relate to:

    public AirplaneLandedMessage: Message
    {
    public Airplane Plane ……
    }

    Here is some real code that I use in massively parallel chain-processing system:

    /// <summary>
    /// Defines a base for items executable by WorkQueue
    /// </summary>
    public interface IWorkItem<TContext> where TContext : class
    {
      /// <summary>
      /// Invoked on an item to perform actual work. 
      /// For example: repaint grid from changed data source, refresh file, send email etc... 
      /// </summary>
      void PerformWork(TContext context);
    
      /// <summary>
      /// Invoked after successfull work execution - when no exception happened
      /// </summary>
      void WorkSucceeded();
    
      /// <summary>
      /// Invoked when either work execution or work success method threw an exception and did not succeed
      /// </summary>
      /// <param name="workPerformed">When true indicates that PerformWork() worked without exception but exception happened later</param>
      void WorkFailed(bool workPerformed, Exception error);
    
    }
    
    
    /// <summary>
    /// Defines contract for work queue that work items can be posted to
    /// </summary>
    public interface IWorkQueue<TContext> where TContext : class
    {
      /// <summary>
      /// Posts work item into the queue in natural queue order (at the end of the queue)
      /// </summary>
      void PostItem(IWorkItem<TContext> work);
    
      long ProcessedSuccessCount{get;}
      long ProcessedFailureCount{get;}
    
      TContext Context { get; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made my first webpart using WSPBuilder. When I try to deploy it
Visual Studio 2010 Express, Windows Forms. Have made myself my first little application which
This is my first winform app in .NET... I have made a couple of
I have made a batch file that call another one program.bat , the first
First off thanks to all the users who have made my android developing adventure
I have made an application for IPad in objective C. In this I am
i have made an application having entity framewrok. It is wpf application, now it
I've made a form to process user input using PHP , and the first
I have several articles about Dependency Injection, and I can see the benefits, especially
I have made a jQuery toggle for a menu that I had in mind.

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.