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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:41:56+00:00 2026-05-27T04:41:56+00:00

I started a small app (C#, .Net4, console app) and it was a basic

  • 0

I started a small app (C#, .Net4, console app) and it was a basic idea for moving files around at home based on rules.

This app has grown and become extremely useful. So my task is to break it into more reusable classes and smaller projects (class libraries).

I have a generic ‘Show’ function that accepts a string, and a error_level id. Based on that, I would output text to my console window in a certain colour. All is fine when it’s all in one big class, but I want to move a method to it’s own class libabry – however, I want it to report updates while it’s processing, to my UI (Console window, for now). When I move it to the class, obviously, class to my ‘Show’ method’, break.

Is there a way I can get messages sent from my class method, back to my UI? It’s messages like, ‘Opened Config file’, ‘Processing 12 new files’, ‘Success’.

And as it happens, the UI gets the messages and displays them, while the method finishes it’s job.

At the moment, it’s a Console App project. My plan is to rip out the working code, keeping the console app for testing, and later, change the ‘UI’ into a nice WPF desktop application. (I’m trying to learn WPF, and decided to use a small project I started ages ago, and ‘skin it’).

  • 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-27T04:41:57+00:00Added an answer on May 27, 2026 at 4:41 am

    I would suggest that you add an interface, implement that interface in your UI, and pass a reference to the class that implements the interface to your new classes.

    This approach should work if you are performing the work in a single thread or multiple threads.

    For example, the interface:

    public interface INotify
    {
        void Notify(string Msg);
    }
    

    the UI:

    public class Form1 : INotify
    {
            // This is the method where you instantiate the new worker process
            public void DoSomeWork() {
                NewClass Worker = New NewClass(this);
            }
    
            public delegate void NotifyDelegate(string Msg);
    
        public void Notify(string Msg)
        {
            txtLog.Text += Msg + Environment.NewLine;
        }
    
        void INotify.Notify(string Msg)
        {
            this.INotify_Notify(Msg);
        }
        private void INotify_Notify(string Msg)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new NotifyDelegate(Notify), Msg);
            }
            else
            {
                this.Notify(Msg);
            }
        }
       }
    

    and the new class (just call notify in this class to send the message):

    public class NewClass
    {
        private INotify m_Notifier;
    
        private void Notify(string Msg)
        {
            m_Notifier.Notify(Msg);
        }
    
        public NewClass(INotify oNotifier)
        {
            m_Notifier = oNotifier;
        }
    }
    

    Update with alternate implementation

    An alternate implementation, which will work with static classes, is to implement a delegate.

    For example, here is the delegate:

    public delegate void NotifyDelegate(string Msg);
    

    Here is the sample static class for the console app:

    static class Program
    {
        private static NotifyDelegate m_Notifier;
        static void Main(string[] args)
        {
            m_Notifier = new NotifyDelegate(Notify);
    
            NewClass oNewClass = new NewClass(m_Notifier);
    
            // Your work code here
        }
        static void Notify(string Msg)
        {
            Console.WriteLine(Msg);
        }
    }
    

    and a revised version of the work class:

    public class NewClass
    {
        private NotifyDelegate m_Notifier;
    
        public void Notify(string Msg)
        {
            m_Notifier.Invoke(Msg);
        }
    
        public NewClass(NotifyDelegate oNotifier)
        {
            m_Notifier = oNotifier;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an existing ASP.NET MVC app that started small and has
I've started on a small game where a player click around on a map
I've started developing a small app which main goal is to draw a map
Firstly, great job on B4A. I've just started, and already have a small app
I have started to code a web app for small businesses, and I have
I've a small c# application which does some sync between two libraries. This has
I have this idea for a small-medium web application that I would like to
Today I started work on a small Java app. I have some experience with
I have just started having a go at developing a small KDE app as
i just started building a small test app to help me learn MVC. i

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.