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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:04:05+00:00 2026-05-24T01:04:05+00:00

For simplicity have a modelview (MyModelView) that contains a Scheduler property which has a

  • 0

For simplicity have a modelview (MyModelView) that contains a Scheduler property which has a timer inside of it (Scheduler). The timer is used to check against the current time, and if they match, signal an ‘event match’ that the modelview should somehow be notified of. Now MyModelView knows about the scheduler, but not the other way around.

public Scheduler()
    {
        ScheduleCollection = new ObservableCollection<Schedule>();

        TimeSpan ts = new TimeSpan(30000);

        _timer = new DispatcherTimer();
        _timer.Interval = ts;
        _timer.Tick += new EventHandler(EventTimerCheck_Tick);
        _timer.Start();

    }
private void EventTimerCheck_Tick(object sender, EventArgs e) 
    {
        eventsToLaunch = LocateCurrentEvents();

        if (eventsToLaunch.Count > 0) { RaiseHasEvents(); }
    }

public void RaiseHasEvents()
    {
       EventHandler handler = this.HasEvents;
        if (handler != null)
        {
            var e = new EventArgs();
            handler(this, e);
        }
    }

public event EventHandler HasEvents;

public MyModelView()
   {

       Scheduler scheduler = new Scheduler();

       HaveEvents += scheduler.HasEvents; <----*throws Error below
    }

   internal event EventHandler HaveEvents;
  • Scheduler.HasEvents’ can only appear on the left hand side of += or -= (except when used from within the type)

How would I raise an event that the MyModelView can subscribe to? Or is this accomplished through RelayCommanding ?

  • 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-24T01:04:06+00:00Added an answer on May 24, 2026 at 1:04 am

    You are trying to add additional handlers to an event exposed by your MyModelView, not handle the event (which is not valid syntax).

    You should be doing something like the following to subscribe to the event:

    public MyModelView() {
        Scheduler scheduler = new Scheduler();
        scheduler.HasEvents += OnHasEvents;
        // ...
    }
    
    private void OnHasEvents(object sender, EventArgs e) {
        // TODO: Do something here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model that has an arbitrary number of children entities. For simplicity
I have an application which has 5 tabs on a TabBarController. For simplicity sake
I have a SQL Server table that contains users & their grades. For simplicity's
I have a windows form which has 1 button (for simplicity). On clicking this
For simplicity, say I have an ArrayList that contains objects of type A, B
I have numerous Web Services in my project that share types. For simplicity I
I have an NSMutableArray that is populated with objects of strings. For simplicity sake
For the sake of simplicity, let's say that we have input strings with this
For the sake of simplicity say I have multiple Xtext DSLs that all describe
I have a numerical analysis program which for simplicity calculates an algorithm similar to:

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.