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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:44+00:00 2026-06-01T20:20:44+00:00

I am just learning about events, delegates and subscribers. I’ve spent the last 2

  • 0

I am just learning about events, delegates and subscribers. I’ve spent the last 2 days researching and wrapping my brain around it all. I am unable to access the information being passed in my EventArgs e value. I have a saved project that wants to be opened. The state of the necessary forms are deserialized into a dictionary. A loop is hit that raises the UnpackRequest passing the key/value with it.

ProjectManager.cs file:

public delegate void EventHandler<TArgs>(object sender, TArgs args) where TArgs : EventArgs;
public event EventHandler<UnpackEventArgs> UnpackRequest;

Then farther down:

ProjectManager.cs file:

//Raise a UnpackEvent //took out virtual
protected  void RaiseUnpackRequest(string key, object value)
{
    if (UnpackRequest != null) //something has been added to the list?
    {
        UnpackEventArgs e = new UnpackEventArgs(key, value);
        UnpackRequest(this, e);
    }
}

Then within the open method, after dictionary gets populated with states of each form:

ProjectManager.cs file:

foreach (var pair in dictPackState) {
    string _key = pair.Key;
    dictUnpackedState[_key] = dictPackState[_key];
    RaiseUnpackRequest(pair.Key, pair.Value); //raises the event.
    }

I have a class for the Event:

public class UnpackEventArgs : EventArgs
{
    private string strKey;
    private object objValue;

    public UnpackEventArgs(string key, object value)
    {
        this.strKey = key;
        this.objValue = value;
    }
    //Public property to read the key/value ..and get them out
    public string Key
    {
        get { return strKey; }  
    }
    public object Value
    { 
        get { return objValue; }
    }
}

I am still working on the code to add subscribers and how the project components get re-constituted in the individual forms. But the part I’m trying to work on now is in the MainForm.cs where I handle the Unpacked Request using the arguements getting passed. My e contains the key values and the key represents where to send the value (which is the form object).

private void HandleUnpackRequest(object sender, EventArgs e)
{
    //reflection happens here. turn key into object
    //why can't i get e.key ??? 
    object holder = e; //holder = VBTools.UnpackEventArgs key... value...all info

    //object goToUnpack = (e.key).GetType();
    //goToUnpack.unpackState(e.value);
}

I think I included all the necessary parts to get any help?! 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-06-01T20:20:45+00:00Added an answer on June 1, 2026 at 8:20 pm

    Change this:

    private void HandleUnpackRequest(object sender, EventArgs e) 
    

    To this:

    private void HandleUnpackRequest(object sender, UnpackEventArgs e) 
    

    Remember your event handler declaration:

    public event EventHandler<UnpackEventArgs> UnpackRequest;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just learning about LINQ to XML in all its glory and frailty,
Just learning about Dependency Injection and Prism... It seems just asking around alot of
I am learning about events in C#. I found out that they are just
I am learning Events and Delegates & started with multiple events now. Just that
I am just learning about app.config in respect of creating custom sections. I have
I'm just learning about SVG, and it seems great but I'm not sure about
I am just learning about computer vision and C#. It seems like two prominent
I'm just learning about python. I'm fairly new. I have the following code that
I'm after some good tips for fluent interfaces in C#. I'm just learning about
I just started learning about CSRF. As per OWASP CSRF Article CSRF is an

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.