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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:10:12+00:00 2026-05-16T00:10:12+00:00

it concerns following: I have two projects which should exists more or less independently

  • 0

it concerns following: I have two projects which should exists more or less independently from each other. Project one is a kind File System Watcher. The other one cosnists of my UI. The file watcher raises an event, if there is a new file. After that, the data from the file should be added to a database. That’s coarsely the background story. The actual problem is that after the file watcher raised an event, I want to notify the UI to update the view of the data. That means, the event should be raised by the file watcher and the event should be registered in the implementation of the UI. The main problem ist now that I need instances of classes from both projects. Obviuosly this results in the circular dependency problem. Of course there is the solution of interfaces for the CP problem, but this won’t solve the problem, that I need the same object for data creation and event registration.
Hopefully you can help me with this problem.
Thanks.

  • 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-16T00:10:13+00:00Added an answer on May 16, 2026 at 12:10 am

    Why do you think you need an UI instance in the business logic assembly?

    To register an event handler, you usually need only the instance from the calling assembly (observer, already contained in the calling assembly) and an instance of the referenced assembly (your assembly containing the filesystem watcher).

    Then you have e.g. the following structure:

    Assembly with logic

    public class MyCustomWatcher
    {   
        public event EventHandler Event;
    
        private void RaiseEventForWhateverReason()
        {
            if (Event != null)
            {
                Event(this, new Args());
            }
        }
       public Data GetData()
       {
        //return the data
       }
    }
    

    Assembly with UI: – both form and the controller types are declared here.

    class Form : System.Windows.Forms.Form
    {
     public void DisplayNotification(Data data)
     {
       //actual code here
     }
    }
    
    class Controller 
    {
        private Form form;
        private MyCustomWatcher watcher;
    
        public void Init()
        {
          this.watcher = CreateWatcher();
          RegisterEvents();
          ShowForm();
        }
        void ShowForm()
        {
         //show
        }
        void RegisterEvents()
        {
            this.watcher.Event += HandleChange;
        }
    
        void HandleChange(object sender /*this will be the instance that raised the event*/, SomeEventArgs e)
        {
            //BTW: this.watcher == sender; //the same instance
    
            form.DisplayNotification(this.watcher.GetData());
        }
    }
    

    Assembly with UI references the assembly with logic. No circular dependency here.

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

Sidebar

Related Questions

I am faced with a small project now,in which I have to present a
Recently, I found myself having to write up some concerns I have about race
My question concerns using aidl.exe (on a Windows system) from the command line. This
I have been refactoring throwaway code which I wrote some years ago in a
It's my understanding that if two threads are reading from the same piece of
I currently have a GAME table with two fields user_id, win win = 1
I have a function that contains two for loops, and I'm using a variable
What are the security concerns of the following scenario? (this is one of those
Im currently working on a small project in which I need to model the
I have a query which takes a long time and I want to optimize

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.