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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:36:32+00:00 2026-06-03T19:36:32+00:00

I am building a .NET solution with a GUI mode(one project) and a console

  • 0

I am building a .NET solution with a GUI mode(one project) and a console mode (another project). Each of these projects references a shared class library that holds the shared logical guts behind each app. I want the DLL to be as isolated as possible from each client application. how can I have the DLL report progress to the gui? Right now, the GUI project references the DLL. VS2010 / .NET won’t let me reference the GUI from the DLL because it would be a circular reference.

How can I do this? Are there any general principles for how to handle this in .NET design, or software design in general? Is there a way to use a callback without a reference to the calling project?

  • 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-03T19:36:33+00:00Added an answer on June 3, 2026 at 7:36 pm

    It sounds to me like you need a custom event in your DLL that you then attach to in your GUI.

    Here’s some code to make it more understandable.

    First off lets create a mock of our DLL that does something similar to loading and also defines an event we can attach to in our GUI that received the completed percentage:

    public class MyDLLType
    {
      public decimal PercentageComplete = 5;
    
      public event EventHandler<CustomEventArgs> StatusChanged;
    
      public virtual void OnStatusChanged(CustomEventArgs e)
      {
       if(StatusChanged != null)
       {
          StatusChanged(this, e);
       }
      }
    
      public void DoSomething()
      {
    
         var eventArgs = new CustomEventArgs();
         eventArgs.PercentageComplete = PercentageComplete;
    
         OnStatusChanged(eventArgs);
    
         if(PercentageComplete < 100)
         {
           Thread.Sleep(500);
           PercentageComplete++;
           DoSomething();
         }
      }
    }
    

    Now we have a mock DLL that exposes a StatusChanged event for our GUI to hook into. Here’s a mock GUI taking advantage of this:

    public class MyGUI
    {
    void Main()
    {
        var myNiceDLLType = new MyDLLType();
        myNiceDLLType.StatusChanged += UpdateStatusChange;
        myNiceDLLType.DoSomething();
    }
    
    public void UpdateStatusChange(object sender, CustomEventArgs e)
    {
     var percentageComplete = e.PercentageComplete;
     Console.WriteLine(percentageComplete);
    }
    }
    

    and Bingo, our GUI is receiving the complete percentage from the DLL without the DLL needing to know anything about the GUI.

    The CustomEventArgs I used above looks like this:

    public class CustomEventArgs : EventArgs
    {
        public decimal PercentageComplete{get;set;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One console application in a .net solution references another console application in the same
I am building several different asp.net mvc 3 web projects all under one solution.
.NET 4, console application. The project is set to 'Debug' mode. The breakpoint being
Where to Add a folder in .net solution so that while building the project
Class file Conflicts in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ is preventing me from building the solution.
I'm building an ASP.Net MVC website. Rather than have everything in one project, I've
Let's imagine I already have a project building .NET 3.5 assembly. Now I want
When building ASP.NET projects there is a certain amount of boilerplate, or plumbing that
I'm building an ASP.NET MVC site where I want one of the Views I
I'm building an ASP.NET solution and it's going to have 2 separate websites -

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.