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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:55:31+00:00 2026-05-24T17:55:31+00:00

I have developed a C# script that opens an XLS file, parses it and

  • 0

I have developed a C# script that opens an XLS file, parses it and creates a list of XML files validating them.
Every main steps of the program is logged with something like this:

Console.WriteLine("Step Creating Xml 1... DONE!)
Console.WriteLine("Step Validating Xml 1... DONE!)

The XLS file path is currently hard-coded and I’m creating a tiny GUI with Windows Forms to allow the user to select the XLS file and read the steps made by the program in a TextBox.

I had no problem in creating the button to open the file dialog to select the XSL file but then, once selected, I’m puzzled on how to code the part to show the program’s steps information to the user.

Which is the most common method to accomplish this task keeping the core program GUI agnostic?

  • 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-24T17:55:32+00:00Added an answer on May 24, 2026 at 5:55 pm

    As said in other answers, raise an event that your GUI handles showing your log text.
    This is a complete examples:

    1) first of all think about what informations carry with the event and extend EventArgs class for define you argument event class. I suppose to expose a string that is your log text:

    public class LogEventArgs : EventArgs
    {
        public string messageEvent {get;set;}
    }        
    

    2) For semplicity suppose to have your MyApplication class that expose a business method you want log. We will define and raise an event from here. Logging will be the private method who raise our log event.

    public class MyApplication
    {
        public void BusinessMethod(){
            this.Logging("first");
            System.Threading.Thread.Sleep(1000);
            this.Logging("second");
            System.Threading.Thread.Sleep(3000);
            this.Logging("third");
         }
    }
    

    3) Implement the event raise. For handle an event we use a delegate, that is both a description of what method declaration must be implemented in the receiver (your GUI) to consume the event and the pointer to the receiver method. We declare the event OnLogging.
    Inside Logging method we raise the event setting the argument with log message. We have to check the not null event handler because if there are no listener for the event, the handle will be null (null pointer to receiver event consumer method).

        public delegate void OnLoggingEventHandler(object sender, LogEventArgs e);
        public event OnLoggingEventHandler OnLogging;
    
        private void Logging(string message)
        {
            LogEventArgs logMessage = new LogEventArgs();
            logMessage.messageEvent = message;
            if (OnLogging != null)
            {
                OnLogging(this, logMessage);
            }
        }
    

    4) Now we have to implement a listener of the event and a method that consume it. Suppose to have a windows form with a button that launch your application business method and a textbox where show log messages. This is our form without event listener and consumer.

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            MyApplication myApp = new MyApplication();
            myApp.BusinessMethod();
        }
    }
    

    5) We define a consumer method that handle the event writing on our textbox the log messages received by the event raised. Of course the method has the same signature of the delegate.

    private void MyApplication_OnLogging(object sender, LogEventArgs e)
    {
        this.textBox1.AppendText(e.messageEvent + "\n");
    }
    

    6) With C# native operator we bind our OnLogging event to the event consumer.

    private void button1_Click(object sender, EventArgs e)
        {
            MyApplication myApp = new MyApplication();
    
            myApp.OnLogging += new MyApplication.OnLoggingEventHandler(MyApplication_OnLogging);
            myApp.BusinessMethod();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a recursive FTP-download script, in PHP5, that allows you to select
I have developed a VB.NET WCF service that recives and sends back data. When
We have developed a website that uses MVC, C#, and jQuery. In one of
We have developed a webservice that sits and runs in the context of a
I have developed a framework that is used by several teams in our organisation.
I want another developer to run a Perl script I have written. The script
I have developed some classes with similar behavior, they all implement the same interface.
I have developed some custom DAO-like classes to meet some very specialized requirements for
We have developed our website(Business users website) in .net Framework 2.0 Our client us
I have developed about 300 Applications which I would like to provide with multi-language

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.