Jump to content
Xtreme .Net Talk

Recondaddy

Members
  • Posts

    5
  • Joined

  • Last visited

About Recondaddy

  • Birthday 06/28/1972

Recondaddy's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Since no one else has responded, I'll update my own post with what I have discovered, thus far. The C# application can employ the HTTPListener class to listen on a particular port for a browser's GET request and respond with an HTML page of data. This can be done synchronously (but only allows one request, at a time) or asynchronously using threading. Maybe when I work out the details, I'll post them back.
  2. Hello everyone, I have written a Windows application in C# that is monitoring production statistics of a machine via OPC and logging to a SQL database. It has just a single user interface. I would like to provide a way for my manager, for example, to access this application via web browser and serve him a single html page with current production data, for instance. I'm not looking for detailed code -- just a high-level view of how this is accomplished. I just need concepts, at the moment - not specific solutions, necessarily. Thanks for any guidance you can provide.
  3. Snarfblam, Thanks for the reply. I had already blown away the code that I was talking about in my first post, but I went back and created some more. This time, I could get NO response to the event. I have Form1, which is the main form. It has two buttons -- the first button creates an instance of Class2, and the second button fires the custom event (MyEvent). When the user clicks on the first button, an instance of Class2 is created. In the Class2 constructor, an instance of Class3 is created. Here is the code for the main form: namespace EventsTesting { public partial class Form1 : Form { //Declare a public event public event EventHandler MyEvent; //Declare a variable for a Class 2 object Class2 secondClass; public Form1() { InitializeComponent(); } //Create Class2 button click event handler private void btnCreateClass2_Click(object sender, EventArgs e) { //Instantiate a new Class2 object secondClass = new Class2(); } //Fire event button click event handler private void btnFireEvent_Click(object sender, EventArgs e) { //If there are any subscribers to the event if (this.MyEvent != null) { //Fire the event this.MyEvent(this, new EventArgs()); } } } } Here is the code for Class2: namespace EventsTesting { class Class2 { //Declare a Form1 object Form1 parentClass; //Declare a Class3 object Class3 childClass; public Class2() { //Instantiate the Form1 object parentClass = new Form1(); //Add an event handler for the Form1 event parentClass.MyEvent += new EventHandler(parentClass_MyEvent); //Notify the user that Class2 has been instantiated MessageBox.Show("Class 2 created!"); //Instantiate the Class3 object childClass = new Class3(); } //Parent class' MyEvent event handler void parentClass_MyEvent(object sender, EventArgs e) { //Show a user message MessageBox.Show("Event consumed in Class 2"); } } } And finally, the code for Class3: namespace EventsTesting { class Class3 { //Declare a Form1 object Form1 grandParentClass; public Class3() { //Instantiate the Form1 object grandParentClass = new Form1(); //Add an event handler for the Form1 MyEvent event grandParentClass.MyEvent += new EventHandler(grandParentClass_MyEvent); //Notify the user that the Class3 object is instantiated MessageBox.Show("Class 3 created!"); } //Event handler for Form1 MyEvent void grandParentClass_MyEvent(object sender, EventArgs e) { //Show user message MessageBox.Show("Event consumed in Class 3"); } } } When I fired the event, nothing happened. When I debugged the program, I found that there were no subscribers to the event. I'm sure this is a very elementary problem, but any help in understanding would be greatly appreciated. Thanks for your time!
  4. Hello everyone. Here's a scenario involving events that I've already tested but am curious about the details. In a Windows Forms application, the main form (of type, Class1) instantiates a new object of type, Class2. This new object instantiates an object of type, Class3. Class1 | Class2 | Class3 An event is fired in the Class1 object. I placed event handlers in the Class2 and Class3 objects to deal with this event, but when the event fires, only the event handler in the Class2 object is executed. Is it true that only objects that were instantiated by an object of a particular class are able to subscribe to that class' events? If so, what is the best way to let the Class3 object subscribe to the events in the Class1 object? Thanks for your insight!
  5. Hello everyone, I'm not a software engineer, so I'm certain this is probably something that you guys see all the time, but it's a first for me. I'm reverse engineering a sample C# console application, and I ran across a scenario I don't quite understand -- a class instantiating itself within itself. Here's a simplified example of what I mean: class Program { static void Subroutine1() { DoSomething } static void Main(string[] args) { Subroutine1(); [b]Program program = new Program();[/b] ... ... ... program.Subroutine2(); } void Subroutine2() { DoSomethingElse } } I hope that's enough to see what I'm talking about. Does anyone know what the developer was trying to accomplish here? Thanks for any help you can provide.
×
×
  • Create New...