• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

State Changes

Hi,

I have a project class which fires several onChange events which I would like to display asynchronously to another window form project using VS.NET 2005. How can I do that?

Thanks,

Yama
0
yamazed
Asked:
yamazed
  • 2
  • 2
1 Solution
 
AlexFMCommented:
Maybe you can give some details. Without this I try to guess:

http://msdn.microsoft.com/msdnmag/issues/06/04/ManagedSpy/
0
 
yamazedAuthor Commented:
Not even close... Here is what I am trying to accomplish:

Say I had the following:

In a class project:

myClass_OnChange(object sender, EventArg e)
{
   myStringBuilder.Append(e.Results);
}

myClassWithinthesameClass_OnChange(object sender, EventArg e)
{
   myStringBuilder.Append(e.Results);
}

I'd like to display results in a textbox on a windows form.

Such that everytime a change happens in class project I display it in the textbox.

Thanks,

Yama
0
 
AlexFMCommented:
Raise event from the class and handle it in the form.

Class code:

public delegate void NewStringHandler(string s);

public class myClass
{
    public event NewStringHandler OnNewString;

    myClass_OnChange(object sender, EventArg e)
    {
       myStringBuilder.Append(e.Results);
       // raise event
       OnNewString(e.Results);
    }
}

In form class:

myClass m = new MyClass();
m.OnNewString += new NewStringHandler(this.OnNewString);   // subscribe to event

void OnNewString(string s)
{
    // handle event
}
0
 
yamazedAuthor Commented:
Hi,

I am getting a null thrown when:

 // raise event
OnNewString(e.Results);

OnNewString is null...

Yama
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now